diff options
author | Cedric BAIL <cedric.bail@free.fr> | 2011-08-30 15:21:44 +0000 |
---|---|---|
committer | Cedric BAIL <cedric.bail@free.fr> | 2011-08-30 15:21:44 +0000 |
commit | 5b83e0a288548ab970b7da9bb0f1e6a7893109a7 (patch) | |
tree | 1e95e9ae2354e1c1fc3bcb613f36096c40d23320 /legacy/edje/src | |
parent | 952e4cef2eeaa1e3e1482f66f02ca6a25ea620f9 (diff) |
edje: less useless call to eina_stringshare_add/del.
NOTE: edje is getting slow this day, please be carefull
when you add code to make it clean and fast. We soon
will require to go after some of this issue. Need to see
why application doing nothing are using 7% of my CPU
(mostly in edje).
SVN revision: 62993
Diffstat (limited to 'legacy/edje/src')
-rw-r--r-- | legacy/edje/src/lib/edje_text.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/legacy/edje/src/lib/edje_text.c b/legacy/edje/src/lib/edje_text.c index cb53fa6..6436f52 100644 --- a/legacy/edje/src/lib/edje_text.c +++ b/legacy/edje/src/lib/edje_text.c | |||
@@ -337,7 +337,6 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, | |||
337 | Edje_Part_Description_Text *chosen_desc) | 337 | Edje_Part_Description_Text *chosen_desc) |
338 | { | 338 | { |
339 | const char *text = NULL; | 339 | const char *text = NULL; |
340 | const char *str; | ||
341 | const char *font; | 340 | const char *font; |
342 | char *font2 = NULL; | 341 | char *font2 = NULL; |
343 | char *sfont = NULL; | 342 | char *sfont = NULL; |
@@ -345,6 +344,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, | |||
345 | Evas_Coord tw, th; | 344 | Evas_Coord tw, th; |
346 | Evas_Coord sw, sh; | 345 | Evas_Coord sw, sh; |
347 | int inlined_font = 0, free_text = 0; | 346 | int inlined_font = 0, free_text = 0; |
347 | Eina_Bool same_text = EINA_FALSE; | ||
348 | FLOAT_T sc; | 348 | FLOAT_T sc; |
349 | 349 | ||
350 | sc = ed->scale; | 350 | sc = ed->scale; |
@@ -352,7 +352,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, | |||
352 | text = edje_string_get(&chosen_desc->text.text); | 352 | text = edje_string_get(&chosen_desc->text.text); |
353 | font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont); | 353 | font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont); |
354 | 354 | ||
355 | if (ep->text.text) text = (char *) ep->text.text; | 355 | if (ep->text.text) text = ep->text.text; |
356 | if (ep->text.font) font = ep->text.font; | 356 | if (ep->text.font) font = ep->text.font; |
357 | if (ep->text.size > 0) size = ep->text.size; | 357 | if (ep->text.size > 0) size = ep->text.size; |
358 | 358 | ||
@@ -408,28 +408,35 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, | |||
408 | } | 408 | } |
409 | 409 | ||
410 | size = params->type.text.size; | 410 | size = params->type.text.size; |
411 | if (!text) text = ""; | ||
412 | |||
413 | if ((text == ep->text.cache.in_str) | ||
414 | || (text && ep->text.cache.in_str && !strcmp(ep->text.cache.in_str, text))) | ||
415 | { | ||
416 | text = ep->text.cache.in_str; | ||
417 | same_text = EINA_TRUE; | ||
418 | } | ||
411 | 419 | ||
412 | if ((ep->text.cache.in_size == size) && | 420 | if ((ep->text.cache.in_size == size) && |
413 | (ep->text.cache.in_w == sw) && | 421 | (ep->text.cache.in_w == sw) && |
414 | (ep->text.cache.in_h == sh) && | 422 | (ep->text.cache.in_h == sh) && |
415 | (ep->text.cache.in_str) && | 423 | (ep->text.cache.in_str) && |
416 | (text) && | 424 | same_text && |
417 | (!strcmp(ep->text.cache.in_str, text)) && | ||
418 | (ep->text.cache.align_x == params->type.text.align.x) && | 425 | (ep->text.cache.align_x == params->type.text.align.x) && |
419 | (ep->text.cache.align_y == params->type.text.align.y) && | 426 | (ep->text.cache.align_y == params->type.text.align.y) && |
420 | (ep->text.cache.elipsis == params->type.text.elipsis) && | 427 | (ep->text.cache.elipsis == params->type.text.elipsis) && |
421 | (ep->text.cache.fit_x == chosen_desc->text.fit_x) && | 428 | (ep->text.cache.fit_x == chosen_desc->text.fit_x) && |
422 | (ep->text.cache.fit_y == chosen_desc->text.fit_y)) | 429 | (ep->text.cache.fit_y == chosen_desc->text.fit_y)) |
423 | { | 430 | { |
424 | text = (char *)ep->text.cache.out_str; | 431 | text = ep->text.cache.out_str; |
425 | size = ep->text.cache.out_size; | 432 | size = ep->text.cache.out_size; |
426 | 433 | ||
427 | if (!text) text = ""; | ||
428 | |||
429 | goto arrange_text; | 434 | goto arrange_text; |
430 | } | 435 | } |
431 | if (ep->text.cache.in_str) eina_stringshare_del(ep->text.cache.in_str); | 436 | if (!same_text) |
432 | ep->text.cache.in_str = eina_stringshare_add(text); | 437 | { |
438 | eina_stringshare_replace(&ep->text.cache.in_str, text); | ||
439 | } | ||
433 | ep->text.cache.in_size = size; | 440 | ep->text.cache.in_size = size; |
434 | if (chosen_desc->text.fit_x && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) | 441 | if (chosen_desc->text.fit_x && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) |
435 | { | 442 | { |
@@ -570,9 +577,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, | |||
570 | text = _edje_text_fit_x(ed, ep, params, text, font, size, sw, &free_text); | 577 | text = _edje_text_fit_x(ed, ep, params, text, font, size, sw, &free_text); |
571 | } | 578 | } |
572 | 579 | ||
573 | str = eina_stringshare_add(text); | 580 | eina_stringshare_replace(&ep->text.cache.out_str, text); |
574 | if (ep->text.cache.out_str) eina_stringshare_del(ep->text.cache.out_str); | ||
575 | ep->text.cache.out_str = str; | ||
576 | ep->text.cache.in_w = sw; | 581 | ep->text.cache.in_w = sw; |
577 | ep->text.cache.in_h = sh; | 582 | ep->text.cache.in_h = sh; |
578 | ep->text.cache.out_size = size; | 583 | ep->text.cache.out_size = size; |