diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2025-01-04 18:04:31 -0700 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-01-04 21:45:18 -0700 |
| commit | dedb8b7ebf103b09c78e5f088f3cc7038b5adc5c (patch) | |
| tree | f9948c5db1f10d249c6d544d6b2b6fd113e09956 /ui-terminal.c | |
| parent | 8a14a8193900f74a986ead962e5ec9950aa8d49d (diff) | |
| download | vis-dedb8b7ebf103b09c78e5f088f3cc7038b5adc5c.tar.gz vis-dedb8b7ebf103b09c78e5f088f3cc7038b5adc5c.tar.xz | |
ui: remove useless memcpy call
If the compiler wants to use memcpy to move 12 bytes it can inline
the call itself otherwise we should just write the simple thing.
Diffstat (limited to 'ui-terminal.c')
| -rw-r--r-- | ui-terminal.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/ui-terminal.c b/ui-terminal.c index 6e78d32..e16e90f 100644 --- a/ui-terminal.c +++ b/ui-terminal.c @@ -245,29 +245,27 @@ static void ui_window_draw(Win *win) { snprintf(buf, sizeof buf, "%*zu ", sidebar_width-1, number); } ui_draw_string(ui, x, y, buf, win, - (l->lineno == cursor_lineno) ? UI_STYLE_LINENUMBER_CURSOR : UI_STYLE_LINENUMBER); + (l->lineno == cursor_lineno) ? UI_STYLE_LINENUMBER_CURSOR : + UI_STYLE_LINENUMBER); prev_lineno = l->lineno; } debug("draw-window: [%d][%d] ... cells[%d][%d]\n", y, x+sidebar_width, y, view_width); - memcpy(&cells[x+sidebar_width], l->cells, sizeof(Cell) * view_width); + memcpy(cells + x + sidebar_width, l->cells, sizeof(Cell) * view_width); cells += ui->width; } } void ui_window_style_set(Win *win, Cell *cell, enum UiStyle id) { Ui *tui = &win->vis->ui; - CellStyle set, style = tui->styles[win->id * UI_STYLE_MAX + id]; + CellStyle set = tui->styles[win->id * UI_STYLE_MAX + id]; - if (id == UI_STYLE_DEFAULT) { - memcpy(&cell->style, &style, sizeof(CellStyle)); - return; + if (id != UI_STYLE_DEFAULT) { + set.fg = is_default_fg(set.fg)? cell->style.fg : set.fg; + set.bg = is_default_bg(set.bg)? cell->style.bg : set.bg; + set.attr = cell->style.attr | set.attr; } - set.fg = is_default_fg(style.fg)? cell->style.fg : style.fg; - set.bg = is_default_bg(style.bg)? cell->style.bg : style.bg; - set.attr = cell->style.attr | style.attr; - - memcpy(&cell->style, &set, sizeof(CellStyle)); + cell->style = set; } bool ui_window_style_set_pos(Win *win, int x, int y, enum UiStyle id) { |
