]> git.eshelyaron.com Git - emacs.git/commitdiff
(Fframe_or_buffer_changed_p): Reuse the state vector.
authorKarl Heuer <kwzh@gnu.org>
Tue, 7 Jun 1994 01:12:36 +0000 (01:12 +0000)
committerKarl Heuer <kwzh@gnu.org>
Tue, 7 Jun 1994 01:12:36 +0000 (01:12 +0000)
src/dispnew.c

index 29b2777fd2063555350d5982ed69aa5688145919..81470fba4ad2752cb7f4a54f2ee8230a847cb479 100644 (file)
@@ -1858,7 +1858,7 @@ update_line (frame, vpos)
   current_frame->charstarts[vpos] = temp1;
 }
 \f
-/* 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 @@ the current state.\n")
     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 @@ the current state.\n")
       *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;
 }
 \f