After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 335195 - GST_BOILERPLATE_FULL etc isn' optimised
GST_BOILERPLATE_FULL etc isn' optimised
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.10.x
Other Linux
: Normal normal
: 0.10.5
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-03-20 09:23 UTC by Ross Burton
Modified: 2006-03-20 17:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (883 bytes, patch)
2006-03-20 15:59 UTC, Ross Burton
none Details | Review

Description Ross Burton 2006-03-20 09:23:55 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.
Comment 1 Jan Schmidt 2006-03-20 15:47:52 UTC
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.
Comment 2 Ross Burton 2006-03-20 15:56:30 UTC
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.
Comment 3 Ross Burton 2006-03-20 15:59:15 UTC
Created attachment 61631 [details] [review]
Patch

Something like this (untested).
Comment 4 Tim-Philipp Müller 2006-03-20 16:09:04 UTC
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
Comment 5 Jan Schmidt 2006-03-20 16:48:16 UTC
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()