Skip to content

Commit

Permalink
fixup! perf(core): enable rendering of substrings to avoid slicing
Browse files Browse the repository at this point in the history
  • Loading branch information
mmilata authored and matejcik committed Jan 11, 2021
1 parent 2cb10ce commit 6541908
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/embed/extmod/modtrezorui/display.c
Expand Up @@ -870,8 +870,8 @@ void display_fade(int start, int end, int delay) {

#define UTF8_IS_CONT(ch) (((ch)&0xC0) == 0x80)

void display_utf8_substr(char *buf_start, size_t buf_len, int char_off,
int char_len, char **out_start, int *out_len) {
void display_utf8_substr(const char *buf_start, size_t buf_len, int char_off,
int char_len, const char **out_start, int *out_len) {
size_t i = 0;

for (; i < buf_len; i++) {
Expand Down
4 changes: 2 additions & 2 deletions core/embed/extmod/modtrezorui/display.h
Expand Up @@ -114,7 +114,7 @@ int display_backlight(int val);
void display_fade(int start, int end, int delay);

// helper for locating a substring in buffer with utf-8 string
void display_utf8_substr(char *buf_start, size_t buf_len, int char_off,
int char_len, char **out_start, int *out_len);
void display_utf8_substr(const char *buf_start, size_t buf_len, int char_off,
int char_len, const char **out_start, int *out_len);

#endif
4 changes: 2 additions & 2 deletions core/embed/extmod/modtrezorui/modtrezorui-display.h
Expand Up @@ -337,7 +337,7 @@ STATIC mp_obj_t mod_trezorui_Display_text(size_t n_args, const mp_obj_t *args) {
mp_int_t fgcolor = mp_obj_get_int(args[5]);
mp_int_t bgcolor = mp_obj_get_int(args[6]);

char *buf_start = text.buf;
const char *buf_start = text.buf;
int buf_len = text.len;
if (n_args > 7) {
mp_int_t off = mp_obj_get_int(args[7]);
Expand Down Expand Up @@ -436,7 +436,7 @@ STATIC mp_obj_t mod_trezorui_Display_text_width(size_t n_args,
mp_get_buffer_raise(args[1], &txt, MP_BUFFER_READ);
mp_int_t f = mp_obj_get_int(args[2]);

char *buf_start = txt.buf;
const char *buf_start = txt.buf;
int buf_len = txt.len;
if (n_args > 3) {
mp_int_t off = mp_obj_get_int(args[3]);
Expand Down

0 comments on commit 6541908

Please sign in to comment.