g_str_has_prefix: don't call strlen(str)
authorDan Winship <danw@gnome.org>
Wed, 9 Apr 2014 13:57:46 +0000 (09:57 -0400)
committerDan Winship <danw@gnome.org>
Thu, 10 Apr 2014 14:10:24 +0000 (10:10 -0400)
commiteec507c15987388ae624eada236032e700bf8c50
tree3969aba3fe805607b5056f540ed591bf54ecfb33
parent0e44b29340a1e3db140064d7c34070904e3fd8be
g_str_has_prefix: don't call strlen(str)

There's no reason to check the length of @str in g_str_has_prefix(),
since if it's shorter than @prefix, the strncmp() will fail anyway.
And besides making the function less efficient, it also breaks code
like:

    if (buf->len >=3 && g_str_has_prefix (buf->data, "foo"))
      ...

which really looks like it ought to work whether buf->data is
nul-terminated or not.

https://bugzilla.gnome.org/show_bug.cgi?id=727890
glib/gstrfuncs.c