changeset 5130:ddee29e260d2

(make_buffer_string): Don't copy intervals if we don't really have any properties. (Finsert_buffer_substring): Pass graft_intervals_into_buffer the current buffer. Pass it the extra arg LENGTH. (Fsubst_char_in_region): Call modify_region only if a change has to be made. Call signal_after_change just once, at end.
author Richard M. Stallman <rms@gnu.org>
date Tue, 23 Nov 1993 10:38:59 +0000
parents d48d18e20316
children 69078817ec92
files src/editfns.c
diffstat 1 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/editfns.c	Tue Nov 23 10:09:44 1993 +0000
+++ b/src/editfns.c	Tue Nov 23 10:38:59 1993 +0000
@@ -890,7 +890,7 @@
 make_buffer_string (start, end)
      int start, end;
 {
-  Lisp_Object result;
+  Lisp_Object result, tem;
 
   if (start < GPT && GPT < end)
     move_gap (start);
@@ -898,8 +898,12 @@
   result = make_uninit_string (end - start);
   bcopy (&FETCH_CHAR (start), XSTRING (result)->data, end - start);
 
-  /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
-  copy_intervals_to_string (result, current_buffer, start, end - start);
+  tem = Fnext_property_change (make_number (start), Qnil, make_number (end));
+
+#ifdef USE_TEXT_PROPERTIES
+  if (XINT (tem) != end)
+    copy_intervals_to_string (result, current_buffer, start, end - start);
+#endif
 
   return result;
 }
@@ -991,7 +995,7 @@
 
   /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
   graft_intervals_into_buffer (copy_intervals (bp->intervals, start, len),
-			       opoint, bp, 0);
+			       opoint, len, current_buffer, 0);
 
   return Qnil;
 }
@@ -1127,6 +1131,7 @@
      Lisp_Object start, end, fromchar, tochar, noundo;
 {
   register int pos, stop, look;
+  int changed = 0;
 
   validate_region (&start, &end);
   CHECK_NUMBER (fromchar, 2);
@@ -1136,7 +1141,6 @@
   stop = XINT (end);
   look = XINT (fromchar);
 
-  modify_region (current_buffer, pos, stop);
   if (! NILP (noundo))
     {
       if (MODIFF - 1 == current_buffer->save_modified)
@@ -1149,15 +1153,23 @@
     {
       if (FETCH_CHAR (pos) == look)
 	{
+	  if (! changed)
+	    {
+	      modify_region (current_buffer, XINT (start), stop);
+	      changed = 1;
+	    }
+
 	  if (NILP (noundo))
 	    record_change (pos, 1);
 	  FETCH_CHAR (pos) = XINT (tochar);
-	  if (NILP (noundo))
-	    signal_after_change (pos, 1, 1);
 	}
       pos++;
     }
 
+  if (changed)
+    signal_after_change (XINT (start),
+			 stop - XINT (start), stop - XINT (start));
+
   return Qnil;
 }