Use small buffer optimization in gfx_animation_ticker_smooth()
Like the previous commit, this one lowers the number of temporary allocations while the menu is up.
This commit is contained in:
parent
0c9499a88e
commit
4ea0f232ef
|
@ -1706,9 +1706,15 @@ bool gfx_animation_ticker_smooth(gfx_animation_ctx_ticker_smooth_t *ticker)
|
||||||
if (src_str_len < 1)
|
if (src_str_len < 1)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
src_char_widths = (unsigned*)calloc(src_str_len, sizeof(unsigned));
|
unsigned small_src_char_widths[64] = {0};
|
||||||
if (!src_char_widths)
|
src_char_widths = small_src_char_widths;
|
||||||
goto end;
|
|
||||||
|
if (src_str_len > ARRAY_SIZE(small_src_char_widths))
|
||||||
|
{
|
||||||
|
src_char_widths = (unsigned*)calloc(src_str_len, sizeof(unsigned));
|
||||||
|
if (!src_char_widths)
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
str_ptr = ticker->src_str;
|
str_ptr = ticker->src_str;
|
||||||
for (i = 0; i < src_str_len; i++)
|
for (i = 0; i < src_str_len; i++)
|
||||||
|
@ -1881,7 +1887,7 @@ bool gfx_animation_ticker_smooth(gfx_animation_ctx_ticker_smooth_t *ticker)
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
if (src_char_widths)
|
if (src_char_widths != small_src_char_widths && src_char_widths)
|
||||||
{
|
{
|
||||||
free(src_char_widths);
|
free(src_char_widths);
|
||||||
src_char_widths = NULL;
|
src_char_widths = NULL;
|
||||||
|
|
Loading…
Reference in New Issue