mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-28 08:26:14 +01:00
g_str_to_ascii(): a couple of minor tweaks
Add a precondition guard and use g_string_sized_new() to avoid some reallocations.
This commit is contained in:
parent
a8ea3dc03b
commit
8491f03581
@ -331,6 +331,8 @@ g_str_to_ascii (const gchar *str,
|
|||||||
GString *result;
|
GString *result;
|
||||||
guint item_id;
|
guint item_id;
|
||||||
|
|
||||||
|
g_return_val_if_fail (str != NULL, NULL);
|
||||||
|
|
||||||
if (g_str_is_ascii (str))
|
if (g_str_is_ascii (str))
|
||||||
return g_strdup (str);
|
return g_strdup (str);
|
||||||
|
|
||||||
@ -339,7 +341,7 @@ g_str_to_ascii (const gchar *str,
|
|||||||
else
|
else
|
||||||
item_id = get_default_item_id ();
|
item_id = get_default_item_id ();
|
||||||
|
|
||||||
result = g_string_new (NULL);
|
result = g_string_sized_new (strlen (str));
|
||||||
|
|
||||||
while (*str)
|
while (*str)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user