From eddd52cba7ee8448e9b05d97d014f268d059e887 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Mon, 13 Nov 2017 14:13:08 -0800 Subject: [PATCH] edje: cache last string search miss to reduce useless call to eina_str_split_full by 3. --- src/lib/edje/edje_private.h | 1 + src/lib/edje/edje_util.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index 9f4d07e..e001d79 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -2565,6 +2565,7 @@ _edje_textblock_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part *_edje_real_part_get(const Edje *ed, const char *part); Edje_Real_Part *_edje_real_part_recursive_get(Edje **ed, const char *part); Edje_Color_Class *_edje_color_class_find(const Edje *ed, const char *color_class); +// The color_class has to be a pointer to an Eet owned string. Edje_Color_Class *_edje_color_class_recursive_find(const Edje *ed, const char *color_class); void _edje_color_class_on_del(Edje *ed, Edje_Part *ep); void _edje_color_class_hash_free(void); diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index fc0015e..e37a8d4 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -5339,6 +5339,7 @@ _edje_real_part_get(const Edje *ed, const char *part) void * _edje_hash_find_helper(const Eina_Hash *hash, const char *key) { + static const char *remember_key = NULL; void *data; int i, j; char **tokens; @@ -5348,8 +5349,12 @@ _edje_hash_find_helper(const Eina_Hash *hash, const char *key) if (data) return data; - tokens = eina_str_split_full(key, "/", 0, &tokens_count); + // We only receive pointer from Eet files as key, we can + // assume them constant over the life time of the program. + if (remember_key == key) + return NULL; + tokens = eina_str_split_full(key, "/", 0, &tokens_count); if ((tokens) && (tokens_count > 1)) { Eina_Strbuf *buf = NULL; @@ -5373,6 +5378,10 @@ _edje_hash_find_helper(const Eina_Hash *hash, const char *key) eina_strbuf_free(buf); } + else + { + remember_key = key; + } if (tokens) { -- 2.7.4