[gtk/wip/baedert/for-master] icontheme: optimize icon_uri_is_symbolic as well
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master] icontheme: optimize icon_uri_is_symbolic as well
- Date: Thu, 29 Aug 2019 14:51:45 +0000 (UTC)
commit ea5932f6d49be51df37722ecc9bcb59d6a3df7b2
Author: Timm Bäder <mail baedert org>
Date: Tue May 28 10:14:52 2019 +0200
icontheme: optimize icon_uri_is_symbolic as well
gtk/gtkicontheme.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 19856edf6f..a6304160d7 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -1638,13 +1638,28 @@ icon_name_is_symbolic (const gchar *icon_name,
return FALSE;
}
-static gboolean
-icon_uri_is_symbolic (const gchar *icon_name)
+static inline gboolean
+icon_uri_is_symbolic (const gchar *icon_name,
+ int icon_name_len)
{
- return g_str_has_suffix (icon_name, "-symbolic.svg")
- || g_str_has_suffix (icon_name, "-symbolic-ltr.svg")
- || g_str_has_suffix (icon_name, "-symbolic-rtl.svg")
- || g_str_has_suffix (icon_name, ".symbolic.png");
+ if (icon_name_len < 0)
+ icon_name_len = strlen (icon_name);
+
+ if (icon_name_len > strlen ("-symbolic.svg"))
+ {
+ if (strcmp (icon_name + icon_name_len - strlen ("-symbolic.svg"), "-symbolic.svg") == 0 ||
+ strcmp (icon_name + icon_name_len - strlen (".symbolic.png"), ".symbolic.png") == 0)
+ return TRUE;
+ }
+
+ if (icon_name_len > strlen ("-symbolic-ltr.svg"))
+ {
+ if (strcmp (icon_name + icon_name_len - strlen ("-symbolic.ltr.svg"), "-symbolic-ltr.svg") == 0 ||
+ strcmp (icon_name + icon_name_len - strlen ("-symbolic.rtl.svg"), "-symbolic-rtl.svg") == 0)
+ return TRUE;
+ }
+
+ return FALSE;
}
static GtkIconInfo *
@@ -3489,7 +3504,7 @@ gtk_icon_info_is_symbolic (GtkIconInfo *icon_info)
if (icon_info->icon_file)
icon_uri = g_file_get_uri (icon_info->icon_file);
- is_symbolic = (icon_uri != NULL) && (icon_uri_is_symbolic (icon_uri));
+ is_symbolic = (icon_uri != NULL) && (icon_uri_is_symbolic (icon_uri, -1));
g_free (icon_uri);
return is_symbolic;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]