changeset 7814:e1e536773850

(Fframe_or_buffer_changed_p): Reuse the state vector.
author Karl Heuer <kwzh@gnu.org>
date Tue, 07 Jun 1994 01:12:36 +0000
parents 1fa576a274b5
children 5d167db8ce8a
files src/dispnew.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/dispnew.c	Mon Jun 06 09:22:14 1994 +0000
+++ b/src/dispnew.c	Tue Jun 07 01:12:36 1994 +0000
@@ -1858,7 +1858,7 @@
   current_frame->charstarts[vpos] = temp1;
 }
 
-/* A vector of size NFRAMES + 3 * NBUFFERS + 1, containing the session's
+/* A vector of size >= NFRAMES + 3 * NBUFFERS + 1, containing the session's
    frames, buffers, buffer-read-only flags, and buffer-modified-flags,
    and a trailing sentinel (so we don't need to add length checks).  */
 static Lisp_Object frame_and_buffer_state;
@@ -1897,7 +1897,10 @@
     n++;
   for (tail = Vbuffer_alist; CONSP (tail); tail = XCONS (tail)->cdr)
     n += 3;
-  frame_and_buffer_state = Fmake_vector (make_number (n), Qlambda);
+  /* Reallocate the vector if it's grown, or if it's shrunk a lot.  */
+  if (n > XVECTOR (frame_and_buffer_state)->size
+      || n < XVECTOR (frame_and_buffer_state)->size / 2)
+    frame_and_buffer_state = Fmake_vector (make_number (n), Qlambda);
   vecp = XVECTOR (frame_and_buffer_state)->contents;
   FOR_EACH_FRAME (tail, frame)
     *vecp++ = frame;
@@ -1908,6 +1911,9 @@
       *vecp++ = XBUFFER (buf)->read_only;
       *vecp++ = Fbuffer_modified_p (buf);
     }
+  /* If we left any slack in the vector, fill it up now.  */
+  for (; n < XVECTOR (frame_and_buffer_state)->size; ++n)
+    *vecp++ = Qlambda;
   return Qt;
 }