cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=eddd52cba7ee8448e9b05d97d014f268d059e887

commit eddd52cba7ee8448e9b05d97d014f268d059e887
Author: Cedric BAIL <[email protected]>
Date:   Mon Nov 13 14:13:08 2017 -0800

    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 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,
 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 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)
 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)
      {

-- 


Reply via email to