Re: Best practise inheritance



Il Tue, 21 Mar 2017 17:55:31 +0000 Tristan Van Berkom <tristan vanberkom codethink co uk> scrisse:

...
  o I believe the lookups with G_TYPE_INSTANCE_GET_PRIVATE() are just
    as cheap as the pointer dereference (as it will be implemented
    using simple pointer arithmetic).

Hi Tristan,

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

Ciao.
-- 
Nicola


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]