aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--terminal.h3
-rw-r--r--vt.c6
2 files changed, 6 insertions, 3 deletions
diff --git a/terminal.h b/terminal.h
index 099e384a..235108af 100644
--- a/terminal.h
+++ b/terminal.h
@@ -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;
diff --git a/vt.c b/vt.c
index 12a5147d..a3ace1f2 100644
--- a/vt.c
+++ b/vt.c
@@ -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]);