Received: from eggs.gnu.org ([2001:4830:134:3::10]:38971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn1vZ-0005hZ-Rz for qemu-devel@nongnu.org; Thu, 22 Sep 2016 07:12:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn1vV-0002Lj-F9 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 07:12:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn1vV-0002Kt-5N for qemu-devel@nongnu.org; Thu, 22 Sep 2016 07:12:25 -0400 From: Markus Armbruster References: <20160911055301.26650-1-lma@suse.com> <20160911055301.26650-1-lma@suse.com> <87zindrup8.fsf@dusky.pond.sub.org> <57DDA45C02000062000996DE@prv-mh.provo.novell.com> <87fuowje3u.fsf@dusky.pond.sub.org> <9ae54df6-e098-8ca9-53c8-1a65eba32dae@suse.de> <87r38f7qzm.fsf@dusky.pond.sub.org> <57E31E25020000620009B116@prv-mh.provo.novell.com> <87shssnxeq.fsf@dusky.pond.sub.org> <20160922085435.GH352@redhat.com> Date: Thu, 22 Sep 2016 13:12:22 +0200 In-Reply-To: <20160922085435.GH352@redhat.com> (Daniel P. Berrange's message of "Thu, 22 Sep 2016 09:54:35 +0100") Message-ID: <87lgykkx2h.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] =?utf-8?b?562U5aSN77yaIFJlOiBbUEFUQ0ggdjJdIG9iamVj?= =?utf-8?q?t=3A_Add_=27help=27_option_for_all_available_backends_and_prope?= =?utf-8?q?rties?= List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, afaerber@suse.de, Lin Ma "Daniel P. Berrange" writes: > On Thu, Sep 22, 2016 at 10:36:45AM +0200, Markus Armbruster wrote: >> Don't make up a description in user_creatable_help_func(), improve the >> description infrastructure and its use so you get more useful ones >> there. >> >> The existing description infrastructure is just Property member >> description and object_property_set_description(). Rarely used, so >> description is generally null. >> >> Calling object_property_set_description() more often could be helpful, >> but to come up with a sensible description string, you need to know what >> the property does. Needs to be left to people actually familiar with >> the objects. >> >> Aside: historically, we add properties to *instances*. All the property >> meta-data gets duplicated for every instance, including property >> descriptions. This is more flexible than adding the meta-data to the >> class. The flexibility is rarely needed, but the price in wasted memory >> is always paid. Only since commit 16bf7f5, we can add it to classes. >> Adding lots of helpful property descriptions would increase the cost of >> instance properties further. > > FWIW, we could easily optimize handling of description strings by > applying the same trick that GLib has done for GObject property > descriptions. > > Almost certainly every call to object_property_set_description is > going to be passing a string literal, not a dynamically allocated > string. So we take advantage of that and in fact mandate that it > is a string literal, and thus avoid the strdup() of description. > > We can place a fun game to enforce this at compile time thus: > > - Rename object_property_set_description() to > object_property_set_description_internal() > > - Add the macro > > #define object_property_set_description(obj, name, desc, errp) \ > object_property_set_description_internal(obj, name, "" desc "", errp) Cute :) > None the less, we really should make an effort to switch things > over to use class properties instead of instance properties, as > its going to save us allocating a 64 byte struct per property > per instance Yes, please. Related: a way to define a bunch of properties as *data*, i.e. an array of property descriptions, commonly static. Reasoning about static data is so much easier than reasoning about code.