[gst-cvs] gstreamer: binaryregistry: Use local values in while/for loops, use branch prediction macros

Edward Hervey bilboed at kemper.freedesktop.org
Tue Jun 30 07:30:44 PDT 2009


Module: gstreamer
Branch: master
Commit: b50ba091642b48a04d54d3b063db08b3629f463f
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=b50ba091642b48a04d54d3b063db08b3629f463f

Author: Edward Hervey <bilboed at bilboed.com>
Date:   Mon Jun 29 11:24:25 2009 +0200

binaryregistry: Use local values in while/for loops, use branch prediction macros

---

 gst/gstregistrybinary.c |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c
index 222e749..78b90e1 100644
--- a/gst/gstregistrybinary.c
+++ b/gst/gstregistrybinary.c
@@ -942,6 +942,7 @@ gst_registry_binary_load_feature (GstRegistry * registry, gchar ** in,
 
   if (GST_IS_ELEMENT_FACTORY (feature)) {
     GstBinaryElementFactory *ef;
+    guint n;
     GstElementFactory *factory = GST_ELEMENT_FACTORY_CAST (feature);
 
     align (*in);
@@ -954,38 +955,43 @@ gst_registry_binary_load_feature (GstRegistry * registry, gchar ** in,
     unpack_string (*in, factory->details.klass, end, fail);
     unpack_string (*in, factory->details.description, end, fail);
     unpack_string (*in, factory->details.author, end, fail);
+    n = ef->npadtemplates;
     GST_DEBUG ("Element factory : '%s' with npadtemplates=%d",
-        factory->details.longname, ef->npadtemplates);
+        factory->details.longname, n);
 
     /* load pad templates */
-    for (i = 0; i < ef->npadtemplates; i++) {
-      if (!gst_registry_binary_load_pad_template (factory, in, end)) {
+    for (i = 0; i < n; i++) {
+      if (G_UNLIKELY (!gst_registry_binary_load_pad_template (factory, in,
+                  end))) {
         GST_ERROR ("Error while loading binary pad template");
         goto fail;
       }
     }
 
     /* load uritypes */
-    if (ef->nuriprotocols) {
-      GST_DEBUG ("Reading %d UriTypes at address %p", ef->nuriprotocols, *in);
+    if (G_UNLIKELY ((n = ef->nuriprotocols))) {
+      GST_DEBUG ("Reading %d UriTypes at address %p", n, *in);
 
       align (*in);
       factory->uri_type = *((guint *) * in);
       *in += sizeof (factory->uri_type);
       /*unpack_element(*in, &factory->uri_type, factory->uri_type, end, fail); */
 
-      factory->uri_protocols = g_new0 (gchar *, ef->nuriprotocols + 1);
-      for (i = 0; i < ef->nuriprotocols; i++) {
+      factory->uri_protocols = g_new0 (gchar *, n + 1);
+      for (i = 0; i < n; i++) {
         unpack_string (*in, str, end, fail);
         factory->uri_protocols[i] = str;
       }
     }
+
     /* load interfaces */
-    GST_DEBUG ("Reading %d Interfaces at address %p", ef->ninterfaces, *in);
-    for (i = 0; i < ef->ninterfaces; i++) {
-      unpack_string (*in, str, end, fail);
-      __gst_element_factory_add_interface (factory, str);
-      g_free (str);
+    if (G_UNLIKELY ((n = ef->ninterfaces))) {
+      GST_DEBUG ("Reading %d Interfaces at address %p", n, *in);
+      for (i = 0; i < n; i++) {
+        unpack_string (*in, str, end, fail);
+        __gst_element_factory_add_interface (factory, str);
+        g_free (str);
+      }
     }
   } else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
     GstBinaryTypeFindFactory *tff;





More information about the Gstreamer-commits mailing list