From ee7e44fbafce8fcab9c9e00b33a781da6efa283e Mon Sep 17 00:00:00 2001 From: shockrah Date: Sat, 2 May 2020 20:44:47 -0700 Subject: [PATCH] inlined a version of putch for better cache locality --- stlio.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/stlio.c b/stlio.c index f02b020..67f1c2e 100644 --- a/stlio.c +++ b/stlio.c @@ -50,6 +50,15 @@ static void __char_set(u8* dest, u8 desire) { *dest = desire; } + +static inline void __put_ch(const char c) { + if(c == '\n') { + frame_buffer_newline(); + } + else { + write_char(c); + } +} u32 read(char* buffer, u32 size) { // try the timing thing again after this u32 bytes = 0; @@ -64,12 +73,12 @@ u32 read(char* buffer, u32 size) { if(pit_timer_ticks - kbd_time < 0x20 && state == KBD_RELEASE) { __char_set(&(buffer[bytes]), (u8)kbd_key); if(kbd_key == '\n') { - putch('\n'); - return bytes; + __put_ch('\n'); + return ++bytes; } bytes++; __char_set(&kbd_state, KBD_WAITING); // reset the kbd_state since we've now used it - putch(kbd_key); + __put_ch(kbd_key); } pit_timer_wait(1); }