registry: speed up _strlen

Make the _strlen function a little tighter
This commit is contained in:
Wim Taymans 2009-10-20 23:27:41 -04:00 committed by Wim Taymans
parent 50b9a3ecc3
commit 5de94ede2f

View file

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