# HG changeset patch # User Eli Zaretskii # Date 1076949384 0 # Node ID 8533bf50dfbb955f9761ca5aa0f1facd60d5f459 # Parent 56a9e0fafedad01efa5a71e559f2dd98a623e42e (prev_read): New static variable. (read_avail_input): Use it to zero out only those slots in buf[] that were used last time we were called. diff -r 56a9e0fafeda -r 8533bf50dfbb src/keyboard.c --- a/src/keyboard.c Mon Feb 16 16:16:16 2004 +0000 +++ b/src/keyboard.c Mon Feb 16 16:36:24 2004 +0000 @@ -6556,6 +6556,11 @@ #ifndef VMS +/* This remembers the last number of characters read, so we could + avoid zeroing out the whole struct input_event buf and instead zero + out only its used slots. */ +static int prev_read = KBD_BUFFER_SIZE; + /* Read any terminal input already buffered up by the system into the kbd_buffer, but do not wait. @@ -6576,7 +6581,7 @@ register int i; int nread; - for (i = 0; i < KBD_BUFFER_SIZE; i++) + for (i = 0; i < prev_read; i++) EVENT_INIT (buf[i]); if (read_socket_hook) @@ -6592,12 +6597,12 @@ /* Determine how many characters we should *try* to read. */ #ifdef WINDOWSNT - return 0; + return (prev_read = 0); #else /* not WINDOWSNT */ #ifdef MSDOS n_to_read = dos_keysns (); if (n_to_read == 0) - return 0; + return (prev_read = 0); #else /* not MSDOS */ #ifdef FIONREAD /* Find out how much input is available. */ @@ -6615,7 +6620,7 @@ n_to_read = 0; } if (n_to_read == 0) - return 0; + return (prev_read = 0); if (n_to_read > sizeof cbuf) n_to_read = sizeof cbuf; #else /* no FIONREAD */ @@ -6706,7 +6711,7 @@ break; } - return nread; + return (prev_read = nread); } #endif /* not VMS */