vt: add branch hinting to PRINT action

This commit is contained in:
Daniel Eklöf 2019-07-06 13:25:36 +02:00
parent 77e349d20d
commit 00c5b27bfa
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 6 additions and 3 deletions

View file

@ -12,6 +12,9 @@
#include "tllist.h"
#define likely(c) __builtin_expect(!!(c), 1)
#define unlikely(c) __builtin_expect(!!(c), 0)
struct wayland {
struct wl_display *display;
struct wl_registry *registry;

6
vt.c
View file

@ -698,7 +698,7 @@ action(struct terminal *term, enum action action, uint8_t c)
break;
case ACTION_PRINT: {
if (term->auto_margin && term->print_needs_wrap) {
if (unlikely(term->print_needs_wrap) && term->auto_margin) {
if (term->cursor.row == term->scroll_region.end - 1) {
term_scroll(term, 1);
term_cursor_to(term, term->cursor.row, 0);
@ -709,7 +709,7 @@ action(struct terminal *term, enum action action, uint8_t c)
struct cell *cell = &term->grid->cur_line[term->cursor.col];
term_damage_update(term, term->cursor.linear, 1);
if (term->insert_mode) {
if (unlikely(term->insert_mode)) {
assert(false && "untested");
grid_memmove(
term->grid, term->cursor.linear + 1, term->cursor.linear,
@ -735,7 +735,7 @@ action(struct terminal *term, enum action action, uint8_t c)
"", "", "", "π", "", "£", "·", /* x - ~ */
};
if (term->charset[term->selected_charset] == CHARSET_GRAPHIC &&
if (unlikely(term->charset[term->selected_charset] == CHARSET_GRAPHIC) &&
c >= 0x41 && c <= 0x7e)
{
strcpy(cell->c, vt100_0[c - 0x41]);