From 62a570e3ea5a4a560825bcdb8b1d1a0ac1072961 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 2 Jun 2018 22:58:19 +0100 Subject: [PATCH] vt: guide the compiler into optimizing the fast path --- Kernel/vt.c | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/Kernel/vt.c b/Kernel/vt.c index 68d76281..8a2c9351 100644 --- a/Kernel/vt.c +++ b/Kernel/vt.c @@ -104,35 +104,38 @@ static void cursor_fix(void) static void charout(unsigned char c) { - if (c == 7) { - do_beep(); - return; - } - if (c == 8) { - cursorx--; - goto fix; - } - if (c == 9) { - do { - charout(' '); - } while (cursorx&7); - goto fix; - } - if (c == 10) { - cursory++; - goto fix; - } - if (c == 13) { - cursorx = 0; - return; - } - if (c == 0x1b) { - vtmode = 1; - return; + /* Fast path printable symbols */ + if (c <= 0x1b) { + if (c == 7) { + do_beep(); + return; + } + if (c == 8) { + cursorx--; + goto fix; + } + if (c == 9) { + do { + charout(' '); + } while (cursorx&7); + goto fix; + } + if (c == 10) { + cursory++; + goto fix; + } + if (c == 13) { + cursorx = 0; + return; + } + if (c == 0x1b) { + vtmode = 1; + return; + } } plot_char(cursory, cursorx, c); cursorx++; - fix: +fix: cursor_fix(); } -- 2.34.1