From a867caf2604b943630d534f7345a571d8a8d9fdb Mon Sep 17 00:00:00 2001 From: "shilpa.singh" Date: Wed, 3 Jun 2015 16:39:42 +0100 Subject: [PATCH] Edje: Add have_selection check to avoid unnecessary function calls Summary: Check for have_selection flag when left/arrow keys are pressed to jump across the selected text, to avoid unnecessary function calls of comparision, copy of sel_start and sel_end pointers. Test Plan: Press left and right arrow keys on selected and normal text. Reviewers: herdsman, tasn Subscribers: SubodhKumar, navnbeet, cedric Differential Revision: https://phab.enlightenment.org/D2621 --- src/lib/edje/edje_entry.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c index c088610dd1..7d816fdb9c 100644 --- a/src/lib/edje/edje_entry.c +++ b/src/lib/edje/edje_entry.c @@ -1502,11 +1502,14 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, } else { - if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0) - evas_textblock_cursor_copy(en->sel_start, en->cursor); - else - evas_textblock_cursor_copy(en->sel_end, en->cursor); - _sel_clear(ed, en->cursor, rp->object, en); + if (en->have_selection) + { + if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0) + evas_textblock_cursor_copy(en->sel_start, en->cursor); + else + evas_textblock_cursor_copy(en->sel_end, en->cursor); + _sel_clear(ed, en->cursor, rp->object, en); + } } } if (evas_textblock_cursor_char_prev(en->cursor)) @@ -1537,11 +1540,14 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, } else { - if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0) - evas_textblock_cursor_copy(en->sel_end, en->cursor); - else - evas_textblock_cursor_copy(en->sel_start, en->cursor); - _sel_clear(ed, en->cursor, rp->object, en); + if (en->have_selection) + { + if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) < 0) + evas_textblock_cursor_copy(en->sel_end, en->cursor); + else + evas_textblock_cursor_copy(en->sel_start, en->cursor); + _sel_clear(ed, en->cursor, rp->object, en); + } } } /* If control is pressed, go to the end of the word */