mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
registry: speed up _strlen
Make the _strlen function a little tighter
This commit is contained in:
parent
50b9a3ecc3
commit
5de94ede2f
1 changed files with 4 additions and 7 deletions
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue