changeset 53991:8533bf50dfbb

(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.
author Eli Zaretskii <eliz@is.elta.co.il>
date Mon, 16 Feb 2004 16:36:24 +0000
parents 56a9e0fafeda
children c5c237251824
files src/keyboard.c
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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 */