summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2016-02-26 09:06:00 +0000
committerTom Hacohen <tom@stosb.com>2016-02-26 09:14:49 +0000
commit00300e7761282cd04a49f8d4f851a670436a3b2f (patch)
treeaeb12936e8dee08eae4448a535562d5aded1f704
parentde0b15310544b8648eae454a17ca3f18fd9e022a (diff)
downloadefl-00300e7761282cd04a49f8d4f851a670436a3b2f.tar.gz
Evas textblock: Fix markup cache, was completely broken.
The markup cache was completely broken. It was not compared correctly, so it wasn't even used, but regardless it was cleared just after being set in some of the cases. This is the first part of a performance regression fix in elm label. @fix
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 70a9e3ae33..02873492ae 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -505,7 +505,7 @@ struct _Evas_Object_Textblock
int l, r, t, b;
} style_pad;
double valign;
- char *markup_text;
+ Eina_Stringshare *markup_text;
void *engine_data;
const char *repch;
const char *bidi_delimiters;
@@ -6473,7 +6473,7 @@ _textblock_style_generic_set(Evas_Object *eo_obj, Evas_Textblock_Style *ts,
Evas_Textblock_Style *old_ts;
if (o->markup_text)
{
- free(o->markup_text);
+ eina_stringshare_del(o->markup_text);
o->markup_text = NULL;
}
@@ -6831,10 +6831,14 @@ _evas_textblock_text_markup_set(Eo *eo_obj EINA_UNUSED, Evas_Textblock_Data *o,
{
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
evas_object_async_block(obj);
- if ((text != o->markup_text) && (o->markup_text))
+
{
- free(o->markup_text);
- o->markup_text = NULL;
+ text = eina_stringshare_add(text);
+ if (text == o->markup_text)
+ {
+ /* Text is the same, do nothing. */
+ return;
+ }
}
_nodes_clear(eo_obj);
@@ -6844,15 +6848,6 @@ _evas_textblock_text_markup_set(Eo *eo_obj EINA_UNUSED, Evas_Textblock_Data *o,
EINA_INLIST_GET(o->text_nodes),
EINA_INLIST_GET(o->cursor->node)));
- if (!o->style && !o->style_user)
- {
- if (text != o->markup_text)
- {
- if (text) o->markup_text = strdup(text);
- }
- return;
- }
-
evas_textblock_cursor_paragraph_first(o->cursor);
evas_object_textblock_text_markup_prepend(o->cursor, text);
@@ -6865,6 +6860,8 @@ _evas_textblock_text_markup_set(Eo *eo_obj EINA_UNUSED, Evas_Textblock_Data *o,
EINA_LIST_FOREACH(o->cursors, l, data)
evas_textblock_cursor_paragraph_first(data);
}
+
+ o->markup_text = text;
}
EAPI void
@@ -7134,7 +7131,7 @@ _evas_textblock_text_markup_get(Eo *eo_obj EINA_UNUSED, Evas_Textblock_Data *o)
free(text_base);
}
- (((Evas_Textblock_Data *)o)->markup_text) = eina_strbuf_string_steal(txt);
+ (((Evas_Textblock_Data *)o)->markup_text) = eina_stringshare_add(eina_strbuf_string_get(txt));
eina_strbuf_free(txt);
markup = (o->markup_text);
@@ -9248,7 +9245,7 @@ _evas_textblock_changed(Evas_Textblock_Data *o, Evas_Object *eo_obj)
o->content_changed = 1;
if (o->markup_text)
{
- free(o->markup_text);
+ eina_stringshare_del(o->markup_text);
o->markup_text = NULL;
}