GNOME Bugzilla – Bug 372461
use G_UNLIKELY(type==0) in get_type functions
Last modified: 2007-08-17 09:10:09 UTC
The G_DEFINE_TYPE macros do this, so I see no reason not to do it also in the manually coded or autogenerated (type builtins) get_type functions.
Created attachment 76207 [details] [review] patch
This looks good to me, but I wonder (without looking much at the code) if some of the manually coded get_type functions shouldn't be replaced by the provided macros instead.
(In reply to comment #0) > The G_DEFINE_TYPE macros do this, so I see no reason not to do it also in the > manually coded or autogenerated (type builtins) get_type functions. thanks, but this is not needed. all those _get_type() functions should actually use g_once_init_{enter|leave} instead, that also implements type_id check likelyness. so if you want to provide a patch, please provide one that makes the _get_type() functions thread-safe (in a new bug report though), gtype.h and glib/tests/onceinit.c:initializer1() contain simple example code.