From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDjH1-00016d-6n for qemu-devel@nongnu.org; Wed, 12 Feb 2014 18:31:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDjGt-000483-Up for qemu-devel@nongnu.org; Wed, 12 Feb 2014 18:31:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14855) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDjGt-00047z-M5 for qemu-devel@nongnu.org; Wed, 12 Feb 2014 18:31:15 -0500 Message-ID: <52FC043F.1090706@redhat.com> Date: Wed, 12 Feb 2014 16:31:11 -0700 From: Eric Blake MIME-Version: 1.0 References: <1392186806-10418-1-git-send-email-cyliu@suse.com> <1392186806-10418-5-git-send-email-cyliu@suse.com> In-Reply-To: <1392186806-10418-5-git-send-email-cyliu@suse.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Mlwwbd2cplUfSL8EWEcPVbI5lie66Kgn2" Subject: Re: [Qemu-devel] [PATCH v20 04/26] add some QemuOpts functions for replace work List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chunyan Liu , qemu-devel@nongnu.org Cc: kwolf@redhat.com, Dong Xu Wang , stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Mlwwbd2cplUfSL8EWEcPVbI5lie66Kgn2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 02/11/2014 11:33 PM, Chunyan Liu wrote: > Add some qemu_opt functions to replace the same functionality of > QEMUOptionParameter handling. >=20 > Signed-off-by: Dong Xu Wang > Signed-off-by: Chunyan Liu > --- > include/qemu/option.h | 9 +++ > util/qemu-option.c | 134 +++++++++++++++++++++++++++++++++++++++++= ++++++++ > 2 files changed, 143 insertions(+), 0 deletions(-) >=20 > +static void qemu_opt_del(QemuOpt *opt); > + > +const char *qemu_opt_get_del(QemuOpts *opts, const char *name) > +{ > + const char *str =3D qemu_opt_get(opts, name); > + QemuOpt *opt =3D qemu_opt_find(opts, name); > + if (opt) { > + qemu_opt_del(opt); Is it any more efficient to reduce the number of times you crawl through the list? For example, instead of crawling the list with qemu_opt_get, why not get teh string directly from the result of qemu_opt_find? Also, you crawl again for qemu_opt_del. Maybe it's unavoidable, and certainly still O(n), so not the end of the world, but worth thinking about. > +void qemu_opts_print_help(QemuOptsList *list) > +{ > + int i; > + printf("Supported options:\n"); Why printf? Might there be callers that want to print to somewhere other than stdout? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Mlwwbd2cplUfSL8EWEcPVbI5lie66Kgn2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJS/ARAAAoJEKeha0olJ0NqNnAH/2TBivWiTMzLJLCl4a6QoOWr dfNv5u3Ws4Qlnn3yfJ9zp418+Q8BWR4kjr/MLCFU5u7eIqVXsDD8OBL4itgVY4Jk Po1lWh+UiEVhd3xP8zi8D5zfA81sVwjbw2k88TPWYHcf/JCW0NYRJhb1Kwf2y+py 2jpRFVYbdzFSo0TKH4vjq9cvaFnngvRJeJpBmSFmmnVMBqA0dDhwVitlUIk/fB4m fbWCI9N20p0yHFlmCm8zAo8JqBo4y3oaEKsCdcZaU/IHUOxugDYnRA9psnPb8nuL aWewFZ3CC306ebmCsC72HJf33qMD8lzPplL3tgYZgwjYKU13qtT9Cg8uMjbooxY= =fAq9 -----END PGP SIGNATURE----- --Mlwwbd2cplUfSL8EWEcPVbI5lie66Kgn2--