[gtk/wip/baedert/icontheme: 3/7] icontheme: Avoid a g_strconcat in get_icon_suffix
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/icontheme: 3/7] icontheme: Avoid a g_strconcat in get_icon_suffix
- Date: Tue, 21 May 2019 14:25:58 +0000 (UTC)
commit 868f2eb7846eeb60ea864a3a1938830e9988cefd
Author: Timm Bäder <mail baedert org>
Date: Tue May 21 11:25:02 2019 +0200
icontheme: Avoid a g_strconcat in get_icon_suffix
We and up calling this code path over 7000 times on startup.
gtk/gtkicontheme.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 809e58d81d..00b3c7e9d0 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -2768,7 +2768,7 @@ best_suffix (IconSuffix suffix,
else
return ICON_SUFFIX_NONE;
}
-
+
static IconSuffix
theme_dir_get_icon_suffix (IconThemeDir *dir,
const gchar *icon_name,
@@ -2780,13 +2780,15 @@ theme_dir_get_icon_suffix (IconThemeDir *dir,
{
if (icon_name_is_symbolic (icon_name))
{
+ int icon_name_len = strlen (icon_name);
+ char icon_name_with_prefix[1024];
/* Look for foo-symbolic.symbolic.png, as the cache only stores the ".png" suffix */
- char *icon_name_with_prefix = g_strconcat (icon_name, ".symbolic", NULL);
- symbolic_suffix = (IconSuffix)gtk_icon_cache_get_icon_flags (dir->cache,
- icon_name_with_prefix,
- dir->subdir_index);
- g_free (icon_name_with_prefix);
+ strncpy (icon_name_with_prefix, icon_name, icon_name_len);
+ strncpy (icon_name_with_prefix + icon_name_len, ".symbolic", strlen (".symbolic") + 1);
+ symbolic_suffix = (IconSuffix)gtk_icon_cache_get_icon_flags (dir->cache,
+ icon_name_with_prefix,
+ dir->subdir_index);
if (symbolic_suffix & ICON_SUFFIX_PNG)
suffix = ICON_SUFFIX_SYMBOLIC_PNG;
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]