summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-11-13 14:13:08 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-11-13 14:13:08 -0800
commiteddd52cba7ee8448e9b05d97d014f268d059e887 (patch)
treedcec01f014e4e8e10daec20734ce0f57d0af9628 /src
parent7c615e183110f26bf6ea1671848cdaae6adfa130 (diff)
edje: cache last string search miss to reduce useless call to eina_str_split_full by 3.
Diffstat (limited to 'src')
-rw-r--r--src/lib/edje/edje_private.h1
-rw-r--r--src/lib/edje/edje_util.c11
2 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 9f4d07ecab..e001d79f23 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,
2565Edje_Real_Part *_edje_real_part_get(const Edje *ed, const char *part); 2565Edje_Real_Part *_edje_real_part_get(const Edje *ed, const char *part);
2566Edje_Real_Part *_edje_real_part_recursive_get(Edje **ed, const char *part); 2566Edje_Real_Part *_edje_real_part_recursive_get(Edje **ed, const char *part);
2567Edje_Color_Class *_edje_color_class_find(const Edje *ed, const char *color_class); 2567Edje_Color_Class *_edje_color_class_find(const Edje *ed, const char *color_class);
2568// The color_class has to be a pointer to an Eet owned string.
2568Edje_Color_Class *_edje_color_class_recursive_find(const Edje *ed, const char *color_class); 2569Edje_Color_Class *_edje_color_class_recursive_find(const Edje *ed, const char *color_class);
2569void _edje_color_class_on_del(Edje *ed, Edje_Part *ep); 2570void _edje_color_class_on_del(Edje *ed, Edje_Part *ep);
2570void _edje_color_class_hash_free(void); 2571void _edje_color_class_hash_free(void);
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index fc0015eac9..e37a8d43f7 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)
5339void * 5339void *
5340_edje_hash_find_helper(const Eina_Hash *hash, const char *key) 5340_edje_hash_find_helper(const Eina_Hash *hash, const char *key)
5341{ 5341{
5342 static const char *remember_key = NULL;
5342 void *data; 5343 void *data;
5343 int i, j; 5344 int i, j;
5344 char **tokens; 5345 char **tokens;
@@ -5348,8 +5349,12 @@ _edje_hash_find_helper(const Eina_Hash *hash, const char *key)
5348 if (data) 5349 if (data)
5349 return data; 5350 return data;
5350 5351
5351 tokens = eina_str_split_full(key, "/", 0, &tokens_count); 5352 // We only receive pointer from Eet files as key, we can
5353 // assume them constant over the life time of the program.
5354 if (remember_key == key)
5355 return NULL;
5352 5356
5357 tokens = eina_str_split_full(key, "/", 0, &tokens_count);
5353 if ((tokens) && (tokens_count > 1)) 5358 if ((tokens) && (tokens_count > 1))
5354 { 5359 {
5355 Eina_Strbuf *buf = NULL; 5360 Eina_Strbuf *buf = NULL;
@@ -5373,6 +5378,10 @@ _edje_hash_find_helper(const Eina_Hash *hash, const char *key)
5373 5378
5374 eina_strbuf_free(buf); 5379 eina_strbuf_free(buf);
5375 } 5380 }
5381 else
5382 {
5383 remember_key = key;
5384 }
5376 5385
5377 if (tokens) 5386 if (tokens)
5378 { 5387 {