Add a precondition guard and use g_string_sized_new() to avoid some
reallocations.
GString *result;
guint item_id;
GString *result;
guint item_id;
+ g_return_val_if_fail (str != NULL, NULL);
+
if (g_str_is_ascii (str))
return g_strdup (str);
if (g_str_is_ascii (str))
return g_strdup (str);
else
item_id = get_default_item_id ();
else
item_id = get_default_item_id ();
- result = g_string_new (NULL);
+ result = g_string_sized_new (strlen (str));