mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
glib: use g_strdup() in g_ascii_strdown(),g_ascii_strup()
g_strndup() internally uses strncpy(), while g_strdup() uses memcpy(). Most likely, memcpy() is faster. Instead of strlen()+g_strndup(), use g_strdup() as we don't need the length.
This commit is contained in:
parent
96b1298871
commit
6955c25e85
@ -1555,9 +1555,10 @@ g_ascii_strdown (const gchar *str,
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
|
||||
if (len < 0)
|
||||
len = (gssize) strlen (str);
|
||||
result = g_strdup (str);
|
||||
else
|
||||
result = g_strndup (str, (gsize) len);
|
||||
|
||||
result = g_strndup (str, (gsize) len);
|
||||
for (s = result; *s; s++)
|
||||
*s = g_ascii_tolower (*s);
|
||||
|
||||
@ -1585,9 +1586,10 @@ g_ascii_strup (const gchar *str,
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
|
||||
if (len < 0)
|
||||
len = (gssize) strlen (str);
|
||||
result = g_strdup (str);
|
||||
else
|
||||
result = g_strndup (str, (gsize) len);
|
||||
|
||||
result = g_strndup (str, (gsize) len);
|
||||
for (s = result; *s; s++)
|
||||
*s = g_ascii_toupper (*s);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user