]> git.eshelyaron.com Git - emacs.git/commitdiff
* buffer.c: #include region-cache.h.
authorJim Blandy <jimb@redhat.com>
Sat, 8 Oct 1994 22:12:12 +0000 (22:12 +0000)
committerJim Blandy <jimb@redhat.com>
Sat, 8 Oct 1994 22:12:12 +0000 (22:12 +0000)
(Fget_buffer_create): Initialize new members of struct buffer.
(Fkill_buffer): Free memory occupied by caches.
(init_buffer_once): Set default value for cache_long_line_scans in
buffer_defaults, and give it a bit in buffer_local_flags.
(syms_of_buffer): Add DEFVAR_PER_BUFFER for cache_long_line_scans.

src/buffer.c

index 61ece33ed86fc1f3fd905f23d0185d29d92db0c8..27c3f8f2e8a4400f0b84e03dd909dc35d5287266 100644 (file)
@@ -34,6 +34,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "window.h"
 #include "commands.h"
 #include "buffer.h"
+#include "region-cache.h"
 #include "indent.h"
 #include "blockinput.h"
 
@@ -248,6 +249,10 @@ The value is never nil.")
   BUF_Z (b) = 1;
   BUF_MODIFF (b) = 1;
 
+  b->newline_cache = 0;
+  b->width_run_cache = 0;
+  b->width_table = Qnil;
+
   /* Put this on the chain of all buffers including killed ones.  */
   b->next = all_buffers;
   all_buffers = b;
@@ -840,6 +845,17 @@ with `delete-process'.")
   b->name = Qnil;
   BLOCK_INPUT;
   BUFFER_FREE (BUF_BEG_ADDR (b));
+  if (b->newline_cache)
+    {
+      free_region_cache (b->newline_cache);
+      b->newline_cache = 0;
+    }
+  if (b->width_run_cache)
+    {
+      free_region_cache (b->width_run_cache);
+      b->width_run_cache = 0;
+    }
+  b->width_table = Qnil;
   UNBLOCK_INPUT;
   b->undo_list = Qnil;
 
@@ -2479,6 +2495,7 @@ init_buffer_once ()
 #endif
   XSETFASTINT (buffer_defaults.fill_column, 70);
   XSETFASTINT (buffer_defaults.left_margin, 0);
+  buffer_defaults.cache_long_line_scans = Qnil;
 
   /* Assign the local-flags to the slots that have default values.
      The local flag is a bit that is used in the buffer
@@ -2518,6 +2535,7 @@ init_buffer_once ()
   XSETFASTINT (buffer_local_flags.abbrev_table, 0x1000);
   XSETFASTINT (buffer_local_flags.display_table, 0x2000);
   XSETFASTINT (buffer_local_flags.syntax_table, 0x8000);
+  XSETFASTINT (buffer_local_flags.cache_long_line_scans, 0x10000);
 #ifdef MSDOS
   XSETFASTINT (buffer_local_flags.buffer_file_type, 0x4000);
 #endif
@@ -2971,6 +2989,23 @@ If the value of the variable is t, undo information is not recorded.");
     "Non-nil means the mark and region are currently active in this buffer.\n\
 Automatically local in all buffers.");
 
+  DEFVAR_PER_BUFFER ("cache-long-line-scans", &current_buffer->cache_long_line_scans, Qnil, 
+    "Non-nil means that Emacs should use caches to handle long lines faster.\n\
+\n\
+Emacs moves from one line to the next by scanning the buffer for\n\
+newlines, and it implements columnar operations like move-to-column by\n\
+scanning the buffer, adding character widths as it goes.  If the\n\
+buffer's lines are very long (say, more than 500 characters), these\n\
+scans can slow Emacs down a great deal.\n\
+\n\
+If this variable is non-nil, Emacs caches the results of its scans,\n\
+and avoids rescanning regions of the buffer until they are modified.\n\
+\n\
+If this variable is non-nil, short scans will become slightly slower,\n\
+and the caches will use memory roughly proportional to the number of\n\
+newlines and characters whose visual representation can occupy more than\n\
+one column.");
+
   DEFVAR_LISP ("transient-mark-mode", &Vtransient_mark_mode,
     "*Non-nil means deactivate the mark when the buffer contents change.");
   Vtransient_mark_mode = Qnil;