On Tue, 21 Mar 2017 at 21:23, S. Jacobi <sjac...@mailueberfall.de> wrote:
> On Tue, 21 Mar 2017 20:53:04 +0000 > Emmanuele Bassi <eba...@gmail.com> wrote: > > > > > Also, do not store a private pointer in your instance structure, and > > use the get_private_instance() function that the G_DEFINE_TYPE macro > > creates for you. > > > So you say whenever I need access to the objects private data I should > call G_TYPE_INSTANCE_GET_PRIVATE, despite the mentioned overhead? > Nope. I said to use the get_instance_private() function generated for your type by the G_DEFINE_TYPE macro, which uses pointer arithmetic and an offset computed when the class is instantiated and it's constant for all instances. The GET_PRIVATE macro has to compute the offset on every invocation, instead. > > > The GObject tutorial has a good introduction on how to define types > > and how to use them. > > > Indeed. It took me a while to walk through it. However, the example > given in [3] has the comment /* Other members, including private data. > */, which would contradict your opinion, or is at least a bit unclear, > because final and derivable types are handled a bit differently. Please, file a bug against the documentation component of the GLib product in Bugzilla, so we can fix this and make it clearer. Ciao, Emmanuele. > > [3] https://developer.gnome.org/gobject/stable/howto-gobject-code.html > > > Ciao, > > Emmanuele. > > On Tue, 21 Mar 2017 at 19:57, Nicola Fontana <n...@entidi.it> wrote: > > > > > > > > the lookup indeed is quite expensive, and looking at the > > > implementation [1] it is not that straightforward. > > > > > > The very same example provided by the official documentation [2] > > > caches that pointer into the instance struct. > > > > > > [1] https://git.gnome.org/browse/glib/tree/gobject/gtype.c#n4709 > > > [2] > > > > https://developer.gnome.org/gobject/stable/gobject-Type-Information.html#g-type-class-add-private > > > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > -- https://www.bassi.io [@] ebassi [@gmail.com] _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list