emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113712: Invalidate region caches only if buffer tex


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r113712: Invalidate region caches only if buffer text is going to be changed.
Date: Tue, 06 Aug 2013 05:31:25 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113712
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Tue 2013-08-06 09:30:18 +0400
message:
  Invalidate region caches only if buffer text is going to be changed.
  * lisp.h (modify_region_1): Remove 3rd arg and rename to...
  (modify_text): ...new prototype.
  (prepare_to_modify_buffer_1): New prototype.
  * textprop.c (modify_region): Rename to...
  (modify_text_properties): ...new function.
  (add_text_properties_1, set_text_properties, Fremove_text_properties)
  (Fremove_list_of_text_properties): Adjust users.
  * insdel.c (modify_region_1): Remove 3rd arg and reimplement as...
  (modify_text): ...new function.
  (prepare_to_modify_buffer): Reimplement mostly as a wrapper for...
  (prepare_to_modify_buffer_1): ...new function.
  * casefiddle.c (casify_region):
  * editfns.c (Fsubst_char_in_region, Ftranslate_region_internal)
  (Ftranspose_regions): Use modify_text.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/casefiddle.c               
casefiddle.c-20091113204419-o5vbwnq5f7feedwu-154
  src/editfns.c                  editfns.c-20091113204419-o5vbwnq5f7feedwu-255
  src/insdel.c                   insdel.c-20091113204419-o5vbwnq5f7feedwu-175
  src/lisp.h                     lisp.h-20091113204419-o5vbwnq5f7feedwu-253
  src/textprop.c                 textprop.c-20091113204419-o5vbwnq5f7feedwu-512
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-08-05 18:05:46 +0000
+++ b/src/ChangeLog     2013-08-06 05:30:18 +0000
@@ -1,3 +1,21 @@
+2013-08-06  Dmitry Antipov  <address@hidden>
+
+       Invalidate region caches only if buffer text is going to be changed.
+       * lisp.h (modify_region_1): Remove 3rd arg and rename to...
+       (modify_text): ...new prototype.
+       (prepare_to_modify_buffer_1): New prototype.
+       * textprop.c (modify_region): Rename to...
+       (modify_text_properties): ...new function.
+       (add_text_properties_1, set_text_properties, Fremove_text_properties)
+       (Fremove_list_of_text_properties): Adjust users.
+       * insdel.c (modify_region_1): Remove 3rd arg and reimplement as...
+       (modify_text): ...new function.
+       (prepare_to_modify_buffer): Reimplement mostly as a wrapper for...
+       (prepare_to_modify_buffer_1): ...new function.
+       * casefiddle.c (casify_region):
+       * editfns.c (Fsubst_char_in_region, Ftranslate_region_internal)
+       (Ftranspose_regions): Use modify_text.
+
 2013-08-05  Stefan Monnier  <address@hidden>
 
        * lisp.mk (lisp): Add nadvice.elc.

=== modified file 'src/casefiddle.c'
--- a/src/casefiddle.c  2013-01-02 16:13:04 +0000
+++ b/src/casefiddle.c  2013-08-06 05:30:18 +0000
@@ -214,7 +214,7 @@
   validate_region (&b, &e);
   start = XFASTINT (b);
   end = XFASTINT (e);
-  modify_region_1 (start, end, false);
+  modify_text (start, end);
   record_change (start, end - start);
   start_byte = CHAR_TO_BYTE (start);
 

=== modified file 'src/editfns.c'
--- a/src/editfns.c     2013-07-19 01:24:35 +0000
+++ b/src/editfns.c     2013-08-06 05:30:18 +0000
@@ -2928,7 +2928,7 @@
          else if (!changed)
            {
              changed = -1;
-             modify_region_1 (pos, XINT (end), false);
+             modify_text (pos, XINT (end));
 
              if (! NILP (noundo))
                {
@@ -3104,7 +3104,7 @@
   pos = XINT (start);
   pos_byte = CHAR_TO_BYTE (pos);
   end_pos = XINT (end);
-  modify_region_1 (pos, end_pos, false);
+  modify_text (pos, end_pos);
 
   cnt = 0;
   for (; pos < end_pos; )
@@ -4615,7 +4615,7 @@
 
   if (end1 == start2)          /* adjacent regions */
     {
-      modify_region_1 (start1, end2, false);
+      modify_text (start1, end2);
       record_change (start1, len1 + len2);
 
       tmp_interval1 = copy_intervals (cur_intv, start1, len1);
@@ -4674,8 +4674,8 @@
         {
          USE_SAFE_ALLOCA;
 
-          modify_region_1 (start1, end1, false);
-          modify_region_1 (start2, end2, false);
+          modify_text (start1, end1);
+          modify_text (start2, end2);
           record_change (start1, len1);
           record_change (start2, len2);
           tmp_interval1 = copy_intervals (cur_intv, start1, len1);
@@ -4708,7 +4708,7 @@
         {
          USE_SAFE_ALLOCA;
 
-          modify_region_1 (start1, end2, false);
+          modify_text (start1, end2);
           record_change (start1, (end2 - start1));
           tmp_interval1 = copy_intervals (cur_intv, start1, len1);
           tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid);
@@ -4741,7 +4741,7 @@
          USE_SAFE_ALLOCA;
 
           record_change (start1, (end2 - start1));
-          modify_region_1 (start1, end2, false);
+          modify_text (start1, end2);
 
           tmp_interval1 = copy_intervals (cur_intv, start1, len1);
           tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid);

=== modified file 'src/insdel.c'
--- a/src/insdel.c      2013-08-02 08:32:32 +0000
+++ b/src/insdel.c      2013-08-06 05:30:18 +0000
@@ -1756,27 +1756,22 @@
   return deletion;
 }
 
-/* Call this if you're about to change the region of current buffer
+/* Call this if you're about to change the text of current buffer
    from character positions START to END.  This checks the read-only
    properties of the region, calls the necessary modification hooks,
    and warns the next redisplay that it should pay attention to that
-   area.
-
-   If PRESERVE_CHARS_MODIFF, do not update CHARS_MODIFF.
-   Otherwise set CHARS_MODIFF to the new value of MODIFF.  */
+   area.  */
 
 void
-modify_region_1 (ptrdiff_t start, ptrdiff_t end, bool preserve_chars_modiff)
+modify_text (ptrdiff_t start, ptrdiff_t end)
 {
   prepare_to_modify_buffer (start, end, NULL);
 
   BUF_COMPUTE_UNCHANGED (current_buffer, start - 1, end);
-
   if (MODIFF <= SAVE_MODIFF)
     record_first_change ();
   MODIFF++;
-  if (! preserve_chars_modiff)
-    CHARS_MODIFF = MODIFF;
+  CHARS_MODIFF = MODIFF;
 
   bset_point_before_scroll (current_buffer, Qnil);
 }
@@ -1792,8 +1787,8 @@
    by holding its value temporarily in a marker.  */
 
 void
-prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
-                         ptrdiff_t *preserve_ptr)
+prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
+                           ptrdiff_t *preserve_ptr)
 {
   struct buffer *base_buffer;
 
@@ -1864,6 +1859,17 @@
     }
 
   signal_before_change (start, end, preserve_ptr);
+  Vdeactivate_mark = Qt;
+}
+
+/* Like above, but called when we know that the buffer text
+   will be modified and region caches should be invalidated.  */
+
+void
+prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
+                         ptrdiff_t *preserve_ptr)
+{
+  prepare_to_modify_buffer_1 (start, end, preserve_ptr);
 
   if (current_buffer->newline_cache)
     invalidate_region_cache (current_buffer,
@@ -1873,10 +1879,8 @@
     invalidate_region_cache (current_buffer,
                              current_buffer->width_run_cache,
                              start - BEG, Z - end);
+}
 
-  Vdeactivate_mark = Qt;
-}
-
 /* These macros work with an argument named `preserve_ptr'
    and a local variable named `preserve_marker'.  */
 

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2013-08-05 04:14:43 +0000
+++ b/src/lisp.h        2013-08-06 05:30:18 +0000
@@ -3370,8 +3370,9 @@
 extern void del_range_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, bool);
 extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t,
                                ptrdiff_t, ptrdiff_t, bool);
-extern void modify_region_1 (ptrdiff_t, ptrdiff_t, bool);
+extern void modify_text (ptrdiff_t, ptrdiff_t);
 extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
+extern void prepare_to_modify_buffer_1 (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
 extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t);
 extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t,
                                 ptrdiff_t, ptrdiff_t);

=== modified file 'src/textprop.c'
--- a/src/textprop.c    2013-07-16 06:39:49 +0000
+++ b/src/textprop.c    2013-08-06 05:30:18 +0000
@@ -93,15 +93,25 @@
   xsignal0 (Qtext_read_only);
 }
 
-/* Prepare to modify the region of BUFFER from START to END.  */
+/* Prepare to modify the text properties of BUFFER from START to END.  */
 
 static void
-modify_region (Lisp_Object buffer, Lisp_Object start, Lisp_Object end)
+modify_text_properties (Lisp_Object buffer, Lisp_Object start, Lisp_Object end)
 {
+  ptrdiff_t b = XINT (start), e = XINT (end);
   struct buffer *buf = XBUFFER (buffer), *old = current_buffer;
 
   set_buffer_internal (buf);
-  modify_region_1 (XINT (start), XINT (end), true);
+
+  prepare_to_modify_buffer_1 (b, e, NULL);
+
+  BUF_COMPUTE_UNCHANGED (buf, b - 1, e);
+  if (MODIFF <= SAVE_MODIFF)
+    record_first_change ();
+  MODIFF++;
+
+  bset_point_before_scroll (current_buffer, Qnil);
+
   set_buffer_internal (old);
 }
 
@@ -1213,9 +1223,9 @@
       ptrdiff_t prev_total_length = TOTAL_LENGTH (i);
       ptrdiff_t prev_pos = i->position;
 
-      modify_region (object, start, end);
+      modify_text_properties (object, start, end);
       /* If someone called us recursively as a side effect of
-        modify_region, and changed the intervals behind our back
+        modify_text_properties, and changed the intervals behind our back
         (could happen if lock_file, called by prepare_to_modify_buffer,
         triggers redisplay, and that calls add-text-properties again
         in the same buffer), we cannot continue with I, because its
@@ -1357,7 +1367,8 @@
    otherwise.  */
 
 Lisp_Object
-set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object 
properties, Lisp_Object object, Lisp_Object coherent_change_p)
+set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object 
properties,
+                    Lisp_Object object, Lisp_Object coherent_change_p)
 {
   register INTERVAL i;
   Lisp_Object ostart, oend;
@@ -1403,7 +1414,7 @@
     }
 
   if (BUFFERP (object) && !NILP (coherent_change_p))
-    modify_region (object, start, end);
+    modify_text_properties (object, start, end);
 
   set_text_properties_1 (start, end, properties, object, i);
 
@@ -1558,9 +1569,9 @@
       ptrdiff_t prev_total_length = TOTAL_LENGTH (i);
       ptrdiff_t prev_pos = i->position;
 
-      modify_region (object, start, end);
+      modify_text_properties (object, start, end);
       /* If someone called us recursively as a side effect of
-        modify_region, and changed the intervals behind our back
+        modify_text_properties, and changed the intervals behind our back
         (could happen if lock_file, called by prepare_to_modify_buffer,
         triggers redisplay, and that calls add-text-properties again
         in the same buffer), we cannot continue with I, because its
@@ -1667,9 +1678,9 @@
 
   /* We are at the beginning of an interval, with len to scan.
      The flag `modified' records if changes have been made.
-     When object is a buffer, we must call modify_region before changes are
-     made and signal_after_change when we are done.
-     We call modify_region before calling remove_properties if modified == 0,
+     When object is a buffer, we must call modify_text_properties
+     before changes are made and signal_after_change when we are done.
+     We call modify_text_properties before calling remove_properties if 
modified == 0,
      and we call signal_after_change before returning if modified != 0. */
   for (;;)
     {
@@ -1693,7 +1704,7 @@
          else if (LENGTH (i) == len)
            {
              if (!modified && BUFFERP (object))
-               modify_region (object, start, end);
+               modify_text_properties (object, start, end);
              remove_properties (Qnil, properties, i, object);
              if (BUFFERP (object))
                signal_after_change (XINT (start), XINT (end) - XINT (start),
@@ -1706,7 +1717,7 @@
              i = split_interval_left (i, len);
              copy_properties (unchanged, i);
              if (!modified && BUFFERP (object))
-               modify_region (object, start, end);
+               modify_text_properties (object, start, end);
              remove_properties (Qnil, properties, i, object);
              if (BUFFERP (object))
                signal_after_change (XINT (start), XINT (end) - XINT (start),
@@ -1717,7 +1728,7 @@
       if (interval_has_some_properties_list (properties, i))
        {
          if (!modified && BUFFERP (object))
-           modify_region (object, start, end);
+           modify_text_properties (object, start, end);
          remove_properties (Qnil, properties, i, object);
          modified = 1;
        }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]