inlined a version of putch for better cache locality

This commit is contained in:
shockrah 2020-05-02 20:44:47 -07:00
parent 9f793bfd2a
commit ee7e44fbaf

15
stlio.c
View File

@ -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);
}