Avoid allocating rest_of_line and file extension

This commit is contained in:
Christian Dywan 2011-05-13 16:29:40 +02:00
parent 16573234e5
commit fad55dc8a1

View file

@ -869,9 +869,11 @@ addons_get_files (AddonsKind kind)
g_assert (kind == ADDONS_USER_SCRIPTS || kind == ADDONS_USER_STYLES); g_assert (kind == ADDONS_USER_SCRIPTS || kind == ADDONS_USER_STYLES);
if (kind == ADDONS_USER_SCRIPTS) if (kind == ADDONS_USER_SCRIPTS)
file_extension = g_strdup (".js"); file_extension = ".js";
else if (kind == ADDONS_USER_STYLES) else if (kind == ADDONS_USER_STYLES)
file_extension = g_strdup (".css"); file_extension = ".css";
else
g_assert_not_reached ();
files = NULL; files = NULL;
@ -895,7 +897,6 @@ addons_get_files (AddonsKind kind)
directories = g_slist_next (directories); directories = g_slist_next (directories);
} }
g_free (file_extension);
g_slist_free (directories); g_slist_free (directories);
return files; return files;
@ -1014,6 +1015,8 @@ css_metadata_from_file (const gchar* filename,
rest_of_line = g_strdup (line); rest_of_line = g_strdup (line);
rest_of_line = g_strstrip (rest_of_line); rest_of_line = g_strstrip (rest_of_line);
line_has_meta = g_str_has_suffix (rest_of_line, "{") ? FALSE : TRUE;
parts = g_strsplit (rest_of_line, " ", 0); parts = g_strsplit (rest_of_line, " ", 0);
i = 0; i = 0;
while (parts[i] && (*parts[i] != '\0' && *parts[i] != '{')) while (parts[i] && (*parts[i] != '\0' && *parts[i] != '{'))
@ -1050,8 +1053,10 @@ css_metadata_from_file (const gchar* filename,
i++; i++;
} }
g_strfreev (parts); g_strfreev (parts);
g_free (rest_of_line);
} }
line_has_meta = g_str_has_suffix (rest_of_line, "{") ? FALSE : TRUE; else
line_has_meta = FALSE;
} }
g_free (line); g_free (line);
} }