diff options
author | William Wilgus <wilgus.william@gmail.com> | 2020-10-28 21:34:40 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2020-11-13 19:14:56 +0000 |
commit | 6c3cc1cbb93209c776f2b7ebad39354129a6871d (patch) | |
tree | d409ff09c6a987c50b65ddb429afef37e79aa37c /apps/gui/skin_engine/skin_render.c | |
parent | 47e1f964273e29c4f6f2923b3bb814b087c7af47 (diff) | |
download | rockbox-6c3cc1cbb93209c776f2b7ebad39354129a6871d.tar.gz rockbox-6c3cc1cbb93209c776f2b7ebad39354129a6871d.zip |
Skin_engine optimize element switches
it takes a lot of code to check validity and dereference a pointer for every numeric tag branch in get_token_value
apparently about 900 bytes actually
Change-Id: If463e755e9bbc73cbd4a02441572d22df9206121
Diffstat (limited to 'apps/gui/skin_engine/skin_render.c')
-rw-r--r-- | apps/gui/skin_engine/skin_render.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c index 67542adc6b..1f777b6672 100644 --- a/apps/gui/skin_engine/skin_render.c +++ b/apps/gui/skin_engine/skin_render.c | |||
@@ -470,42 +470,40 @@ static void fix_line_alignment(struct skin_draw_info *info, struct skin_element | |||
470 | { | 470 | { |
471 | struct align_pos *align = &info->align; | 471 | struct align_pos *align = &info->align; |
472 | char *cur_pos = info->cur_align_start + strlen(info->cur_align_start); | 472 | char *cur_pos = info->cur_align_start + strlen(info->cur_align_start); |
473 | char *next_pos = cur_pos + 1; | ||
473 | switch (element->tag->type) | 474 | switch (element->tag->type) |
474 | { | 475 | { |
475 | case SKIN_TOKEN_ALIGN_LEFT: | 476 | case SKIN_TOKEN_ALIGN_LEFT: |
476 | *cur_pos = '\0'; cur_pos++; *cur_pos = '\0'; | 477 | align->left = next_pos; |
477 | align->left = cur_pos; | 478 | info->cur_align_start = next_pos; |
478 | info->cur_align_start = cur_pos; | ||
479 | break; | 479 | break; |
480 | case SKIN_TOKEN_ALIGN_LEFT_RTL: | 480 | case SKIN_TOKEN_ALIGN_LEFT_RTL: |
481 | *cur_pos = '\0'; cur_pos++; *cur_pos = '\0'; | 481 | if (UNLIKELY(lang_is_rtl())) |
482 | if (lang_is_rtl()) | 482 | align->right = next_pos; |
483 | align->right = cur_pos; | ||
484 | else | 483 | else |
485 | align->left = cur_pos; | 484 | align->left = next_pos; |
486 | info->cur_align_start = cur_pos; | 485 | info->cur_align_start = next_pos; |
487 | break; | 486 | break; |
488 | case SKIN_TOKEN_ALIGN_CENTER: | 487 | case SKIN_TOKEN_ALIGN_CENTER: |
489 | *cur_pos = '\0'; cur_pos++; *cur_pos = '\0'; | 488 | align->center = next_pos; |
490 | align->center = cur_pos; | 489 | info->cur_align_start = next_pos; |
491 | info->cur_align_start = cur_pos; | ||
492 | break; | 490 | break; |
493 | case SKIN_TOKEN_ALIGN_RIGHT: | 491 | case SKIN_TOKEN_ALIGN_RIGHT: |
494 | *cur_pos = '\0'; cur_pos++; *cur_pos = '\0'; | 492 | align->right = next_pos; |
495 | align->right = cur_pos; | 493 | info->cur_align_start = next_pos; |
496 | info->cur_align_start = cur_pos; | ||
497 | break; | 494 | break; |
498 | case SKIN_TOKEN_ALIGN_RIGHT_RTL: | 495 | case SKIN_TOKEN_ALIGN_RIGHT_RTL: |
499 | *cur_pos = '\0'; cur_pos++; *cur_pos = '\0'; | 496 | if (UNLIKELY(lang_is_rtl())) |
500 | if (lang_is_rtl()) | 497 | align->left = next_pos; |
501 | align->left = cur_pos; | ||
502 | else | 498 | else |
503 | align->right = cur_pos; | 499 | align->right = next_pos; |
504 | info->cur_align_start = cur_pos; | 500 | info->cur_align_start = next_pos; |
505 | break; | 501 | break; |
506 | default: | 502 | default: |
507 | break; | 503 | return; |
508 | } | 504 | } |
505 | *cur_pos = '\0'; | ||
506 | *next_pos = '\0'; | ||
509 | } | 507 | } |
510 | 508 | ||
511 | /* Draw a LINE element onto the display */ | 509 | /* Draw a LINE element onto the display */ |