From 6c3cc1cbb93209c776f2b7ebad39354129a6871d Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 28 Oct 2020 21:34:40 -0400 Subject: 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 --- apps/gui/skin_engine/skin_render.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'apps/gui/skin_engine/skin_render.c') 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 { struct align_pos *align = &info->align; char *cur_pos = info->cur_align_start + strlen(info->cur_align_start); + char *next_pos = cur_pos + 1; switch (element->tag->type) { case SKIN_TOKEN_ALIGN_LEFT: - *cur_pos = '\0'; cur_pos++; *cur_pos = '\0'; - align->left = cur_pos; - info->cur_align_start = cur_pos; + align->left = next_pos; + info->cur_align_start = next_pos; break; case SKIN_TOKEN_ALIGN_LEFT_RTL: - *cur_pos = '\0'; cur_pos++; *cur_pos = '\0'; - if (lang_is_rtl()) - align->right = cur_pos; + if (UNLIKELY(lang_is_rtl())) + align->right = next_pos; else - align->left = cur_pos; - info->cur_align_start = cur_pos; + align->left = next_pos; + info->cur_align_start = next_pos; break; case SKIN_TOKEN_ALIGN_CENTER: - *cur_pos = '\0'; cur_pos++; *cur_pos = '\0'; - align->center = cur_pos; - info->cur_align_start = cur_pos; + align->center = next_pos; + info->cur_align_start = next_pos; break; case SKIN_TOKEN_ALIGN_RIGHT: - *cur_pos = '\0'; cur_pos++; *cur_pos = '\0'; - align->right = cur_pos; - info->cur_align_start = cur_pos; + align->right = next_pos; + info->cur_align_start = next_pos; break; case SKIN_TOKEN_ALIGN_RIGHT_RTL: - *cur_pos = '\0'; cur_pos++; *cur_pos = '\0'; - if (lang_is_rtl()) - align->left = cur_pos; + if (UNLIKELY(lang_is_rtl())) + align->left = next_pos; else - align->right = cur_pos; - info->cur_align_start = cur_pos; + align->right = next_pos; + info->cur_align_start = next_pos; break; default: - break; + return; } + *cur_pos = '\0'; + *next_pos = '\0'; } /* Draw a LINE element onto the display */ -- cgit v1.2.3