Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

short circuit is_diacritic for 5-15% text drawing speed-up

characters less than the first diacritic in the symbol table (0x300)
return false after checking the MRU table

we gain some performance by eliding the function call all together if less than first diacritic

Change-Id: I02c14e350eb168eca808523affad443cd43888b4

+16 -6
+1 -1
firmware/common/diacritic.c
··· 50 50 static const struct diac_range diac_ranges[] = 51 51 { 52 52 DIAC_RANGE_ENTRY(0x0000, 0x0000, 0), 53 - DIAC_RANGE_ENTRY(0x0300, 0x0370, 0), 53 + DIAC_RANGE_ENTRY(FIRST_DIACRITIC, 0x0370, 0), 54 54 DIAC_RANGE_ENTRY(0x0483, 0x048a, 0), 55 55 DIAC_RANGE_ENTRY(0x0591, 0x05be, 1), 56 56 DIAC_RANGE_ENTRY(0x05bf, 0x05c0, 1),
+3 -3
firmware/drivers/lcd-bitmap-common.c
··· 434 434 if (x >= vp->width) 435 435 break; 436 436 437 - is_diac = is_diacritic(*ucs, &is_rtl); 437 + is_diac = IS_DIACRITIC_RTL(*ucs, &is_rtl); 438 438 439 439 /* Get proportional width and glyph bits */ 440 440 width = font_get_width(pf, *ucs); ··· 450 450 const unsigned short *u; 451 451 452 452 /* Jump to next non-diacritic char, and calc its width */ 453 - for (u = &ucs[1]; *u && is_diacritic(*u, NULL); u++); 453 + for (u = &ucs[1]; *u && IS_DIACRITIC(*u); u++); 454 454 455 455 rtl_next_non_diac_width = *u ? font_get_width(pf, *u) : 0; 456 456 } ··· 510 510 if (next_ch) 511 511 { 512 512 bool next_is_rtl; 513 - bool next_is_diacritic = is_diacritic(next_ch, &next_is_rtl); 513 + bool next_is_diacritic = IS_DIACRITIC_RTL(next_ch, &next_is_rtl); 514 514 515 515 /* Increment if: 516 516 * LTR: Next char is not diacritic,
+1 -1
firmware/font.c
··· 1084 1084 1085 1085 for (str = utf8decode(str, &ch); ch != 0 && b < maxbytes; str = utf8decode(str, &ch), b--) 1086 1086 { 1087 - if (is_diacritic(ch, NULL)) 1087 + if (IS_DIACRITIC(ch)) 1088 1088 continue; 1089 1089 1090 1090 /* get proportional width and glyph bits*/
+11 -1
firmware/include/diacritic.h
··· 22 22 #define _DIACRITIC_H_ 23 23 #include "system.h" 24 24 25 + #define FIRST_DIACRITIC (0x0300) 25 26 /* Tests whether a given charactor code is a diacritic mark. 26 27 * Sets is_rtl (if it's not NULL) to whether the character 27 28 * belongs to an RTL language. 28 - */ 29 + */ 29 30 bool is_diacritic(const unsigned short char_code, bool *is_rtl); 31 + 32 + /* Note IS_DIACRITIC macros may elide the function call 33 + * therefore there is a separate _RTL version that requires a bool pointer 34 + * as it sets the variable to false when the is_diacritic func is skipped 35 + */ 36 + #define IS_DIACRITIC(c) (c >= FIRST_DIACRITIC && is_diacritic(c, NULL)) 37 + /* sets the rtl variable to false when function call is skipped */ 38 + #define IS_DIACRITIC_RTL(c, rtl) ((c >= FIRST_DIACRITIC || ( (*rtl = false) )) && is_diacritic(c, rtl)) 39 + 30 40 #endif