edje: cache last string search miss to reduce useless call to eina_str_split_full by 3.

This commit is contained in:
Cedric BAIL 2017-11-13 14:13:08 -08:00
parent 7c615e1831
commit eddd52cba7
2 changed files with 11 additions and 1 deletions

View File

@ -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);

View File

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