bu5hm4n pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=bfaec01987d4dc226357219220107ec02b7ddf48
commit bfaec01987d4dc226357219220107ec02b7ddf48 Author: Ali Alzyod <[email protected]> Date: Tue Apr 23 15:46:47 2019 +0000 elm_entry: speed up setting text (check if same text is already set), fix setting same text pointer This patch deal with two cases: 1- Setting text in Entry (elm_entry_entry_set) , as the one get using (elm_entry_entry_get), caused the entry to become empty. * becase entry string was free inside the elm_entry_entry_set function, without checking new passed string. Now we check if same string was passed to the function, then nothing need to be changed. ``` // Old Behaviour : Entry will become empty // New Behaviour : Entry will Skip setting same text elm_entry_entry_set(app->entry, elm_entry_entry_get(app->entry)); ``` 2- Setting text in Entry (elm_entry_entry_set) , with same content string. * internally entry will set empty string then set passed string, which will case recalculation and re-render the entry element. Now we check if same string data that is passed to the function is the same of the entry content, then nothing need to be changed. ``` // This will be skiped internally since same text is set elm_entry_entry_set(app->entry, "aaaaa"); elm_entry_entry_set(app->entry, "aaaaa"); //skipped ``` Reviewed-by: Marcel Hollerbach <[email protected]> Differential Revision: https://phab.enlightenment.org/D8572 --- src/lib/elementary/elm_entry.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c index 7478a40fd8..2a6ad77518 100644 --- a/src/lib/elementary/elm_entry.c +++ b/src/lib/elementary/elm_entry.c @@ -3314,6 +3314,7 @@ static Eina_Bool _elm_entry_text_set(Eo *obj, Elm_Entry_Data *sd, const char *part, const char *entry) { int len = 0; + const char * current_text = NULL; if (!entry) entry = ""; if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE)) @@ -3327,8 +3328,6 @@ _elm_entry_text_set(Eo *obj, Elm_Entry_Data *sd, const char *part, const char *e } evas_event_freeze(evas_object_evas_get(obj)); - ELM_SAFE_FREE(sd->text, eina_stringshare_del); - sd->changed = EINA_TRUE; /* Clear currently pending job if there is one */ if (sd->append_text_idler) @@ -3345,6 +3344,14 @@ _elm_entry_text_set(Eo *obj, Elm_Entry_Data *sd, const char *part, const char *e sd->append_text_left = NULL; } + /* If old and new text are the same do nothing */ + current_text = edje_object_part_text_get(sd->entry_edje, "elm.text"); + if (current_text == entry || !strcmp(entry, current_text)) + goto done; + + ELM_SAFE_FREE(sd->text, eina_stringshare_del); + sd->changed = EINA_TRUE; + /* Need to clear the entry first */ sd->cursor_pos = edje_object_part_text_cursor_pos_get (sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN); @@ -3356,6 +3363,7 @@ _elm_entry_text_set(Eo *obj, Elm_Entry_Data *sd, const char *part, const char *e else _elm_entry_guide_update(obj, EINA_FALSE); +done: evas_event_thaw(evas_object_evas_get(obj)); evas_event_thaw_eval(evas_object_evas_get(obj)); return EINA_TRUE; --
