diff src/buffer.c @ 9403:9f797989b817

* buffer.c: #include region-cache.h. (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.
author Jim Blandy <jimb@redhat.com>
date Sat, 08 Oct 1994 22:12:12 +0000
parents f6dc29e7e986
children b429144f6ace
line wrap: on
line diff
--- a/src/buffer.c	Sat Oct 08 22:11:16 1994 +0000
+++ b/src/buffer.c	Sat Oct 08 22:12:12 1994 +0000
@@ -34,6 +34,7 @@
 #include "window.h"
 #include "commands.h"
 #include "buffer.h"
+#include "region-cache.h"
 #include "indent.h"
 #include "blockinput.h"
 
@@ -248,6 +249,10 @@
   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 @@
   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 @@
 #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 @@
   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 @@
     "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;