GNOME Bugzilla – Bug 335195
GST_BOILERPLATE_FULL etc isn' optimised
Last modified: 2006-03-20 17:43:57 UTC
If you compare GST_BOILERPLATE_FULL to the equivilant code in GLib you'll see that the GLib code is more efficient: it uses G_UNLIKELY to wrap the type construction, and interns the strings first. This reduces the number of strings copies (works assuming plugins are never unloaded) and optimises get_type() for the common case.
which equivalent code in GLib do you mean? Also, I'm not sure which strings it's useful to intern. from a quick glance, it looks like adding G_UNLIKELY to the if (type == 0) check would be sufficient.
G_DEFINE_TYPE is the very similar code in GLib. Basically a G_UNLIKELY() around the if statement as you said, and g_intern_static_string() around the type name when passing it to gtype.
Created attachment 61631 [details] [review] Patch Something like this (untested).
g_intern_static_string() only exists since GLib-2.10, yet GStreamer only requires GLib-2.6/2.8, so we should probably punt that bit until our GLib requirements are >= 2.10
I agree with Tim, so punting the intern part of the patch until later. Committing the G_UNLIKELY bit though, since every little bit helps :-) * gst/gstutils.h: Add G_UNLIKELY to our boilerplate to optimise the 'already registered the type' case. (Closes: #335195 for now). In the future, when we depend on GLib 2.10, we could also intern the type name using g_intern_static_string()