[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] Stick to loops (was: [PATCH v3 1/5] qom: introduce obje
From: |
Daniel P. Berrange |
Subject: |
Re: [Qemu-devel] Stick to loops (was: [PATCH v3 1/5] qom: introduce object_property_foreach method) |
Date: |
Tue, 13 Oct 2015 13:09:32 +0100 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
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 :|
[Qemu-devel] [PATCH v3 5/5] qom: allow properties to be registered against classes, Daniel P. Berrange, 2015/10/08
[Qemu-devel] [PATCH v3 2/5] qmp: convert to use object_property_foreach iterators, Daniel P. Berrange, 2015/10/09
[Qemu-devel] [PATCH v3 4/5] qom: replace object property list with GHashTable, Daniel P. Berrange, 2015/10/09
Re: [Qemu-devel] [PATCH v3 0/5] qom: more efficient object property handling, Eric Blake, 2015/10/09
Re: [Qemu-devel] [PATCH v3 0/5] qom: more efficient object property handling, Pavel Fedin, 2015/10/09