On Mon, Oct 12, 2015 at 11:00:04AM +0100, Daniel P. Berrange wrote:
> On Fri, Oct 09, 2015 at 10:31:26AM +0200, Markus Armbruster wrote:
> > We have quite a few _foreach-functions to help iterate over various
> > things. They are easy enough to write, but I find them awkward to use.
> >
> > Implementing bdrv_next() is no harder than bdrv_iterate(). Compare:
> >
> > BlockDriverState *bdrv_next(BlockDriverState *bs)
> > {
> > if (!bs) {
> > return QTAILQ_FIRST(&bdrv_states);
> > }
> > return QTAILQ_NEXT(bs, device_list);
> > }
> >
> > void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), void
> > *opaque)
> > {
> > BlockDriverState *bs;
> >
> > QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
> > it(opaque, bs);
> > }
> > }
>
> I don't think your example here is a reasonable comparison when you consider
> the full extent of this patch series. You are only having to iterate over a
> single data structure here. At the end of this patch series we have to
> iterate over multiple data structures spread across the object instance
> and class hierarchy, so writing a 'next' like method is not as trivial
> as you suggest with this comparison.
So it turns out I was wrong here. After a little more thinking I found
it was in fact fairly trivial to support a "next" like iterator in this
QOM property scenario, even when taking class properties into account.
So I'll re-spin this patch series with that approach, since it makes
the diffs much smaller
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|