registry: speed up _strlen
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 21 Oct 2009 03:27:41 +0000 (23:27 -0400)
committerWim Taymans <wim@metal.(none)>
Wed, 21 Oct 2009 03:27:41 +0000 (23:27 -0400)
Make the _strlen function a little tighter

gst/gstregistrychunks.c

index 9e20ef4..d81542b 100644 (file)
@@ -48,15 +48,12 @@ _strnlen (const gchar * str, gint maxlen)
 {
   gint len = 0;
 
-  if (G_UNLIKELY (len == maxlen))
-    return -1;
-
-  while (*str++ != '\0') {
+  while (G_LIKELY (len < maxlen)) {
+    if (G_UNLIKELY (str[len] == '\0'))
+      return len;
     len++;
-    if (G_UNLIKELY (len == maxlen))
-      return -1;
   }
-  return len;
+  return -1;
 }
 
 /* Macros */