bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#16526: 24.3.50; scroll-conservatively & c-mode regression


From: Stefan Monnier
Subject: bug#16526: 24.3.50; scroll-conservatively & c-mode regression
Date: Fri, 04 Jul 2014 15:43:02 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

> I'm not sure what I'm meant to see, but it has made no perceptible
> difference to the "slow" invocation of scan-lists.  In particular, that
> invocation took 0.7196781635284424 seconds with the patch, which is
> "exactly" (near enough) what it took before.

OK, the initialization needs to be after the "lossage:" label,
of course.  Try the patch below instead,


        Stefan


=== modified file 'src/syntax.c'
--- src/syntax.c        2014-02-08 05:12:47 +0000
+++ src/syntax.c        2014-07-04 19:42:50 +0000
@@ -530,17 +530,6 @@
 {
   ptrdiff_t opoint = PT, opoint_byte = PT_BYTE;
 
-  if (!open_paren_in_column_0_is_defun_start)
-    {
-      find_start_value = BEGV;
-      find_start_value_byte = BEGV_BYTE;
-      find_start_buffer = current_buffer;
-      find_start_modiff = MODIFF;
-      find_start_begv = BEGV;
-      find_start_pos = pos;
-      return BEGV;
-    }
-
   /* Use previous finding, if it's valid and applies to this inquiry.  */
   if (current_buffer == find_start_buffer
       /* Reuse the defun-start even if POS is a little farther on.
@@ -550,7 +539,20 @@
       && pos >= find_start_value
       && BEGV == find_start_begv
       && MODIFF == find_start_modiff)
+    {
+      if (!open_paren_in_column_0_is_defun_start)
+       fprintf (stderr, "Optimized lossage by %d (%d%%)!\n",
+                find_start_value - BEGV,
+                100 * (find_start_value - BEGV) / (pos - BEGV));
     return find_start_value;
+    }
+
+  if (!open_paren_in_column_0_is_defun_start)
+    {
+      find_start_value = BEGV;
+      find_start_value_byte = BEGV_BYTE;
+      goto found;
+    }
 
   /* Back up to start of line.  */
   scan_newline (pos, pos_byte, BEGV, BEGV_BYTE, -1, 1);
@@ -582,13 +584,14 @@
   /* Record what we found, for the next try.  */
   find_start_value = PT;
   find_start_value_byte = PT_BYTE;
+  TEMP_SET_PT_BOTH (opoint, opoint_byte);
+
+ found:
   find_start_buffer = current_buffer;
   find_start_modiff = MODIFF;
   find_start_begv = BEGV;
   find_start_pos = pos;
 
-  TEMP_SET_PT_BOTH (opoint, opoint_byte);
-
   return find_start_value;
 }
 
@@ -841,7 +844,9 @@
   else
     {
       struct lisp_parse_state state;
+      bool adjusted;
     lossage:
+      adjusted = false;
       /* We had two kinds of string delimiters mixed up
         together.  Decode this going forwards.
         Scan fwd from a known safe place (beginning-of-defun)
@@ -852,6 +857,8 @@
        {
          defun_start = find_defun_start (comment_end, comment_end_byte);
          defun_start_byte = find_start_value_byte;
+         if (defun_start != BEGV)
+           adjusted = true;
        }
       do
        {
@@ -860,6 +867,16 @@
                              comment_end, TYPE_MINIMUM (EMACS_INT),
                              0, Qnil, 0);
          defun_start = comment_end;
+         if (!adjusted)
+           {
+             adjusted = true;
+             find_start_value
+               = CONSP (state.levelstarts) ? XINT (XCAR (state.levelstarts))
+               : state.thislevelstart >= 0 ? state.thislevelstart
+               : find_start_value;
+             find_start_value_byte = CHAR_TO_BYTE (find_start_value);
+           }
+
          if (state.incomment == (comnested ? 1 : -1)
              && state.comstyle == comstyle)
            from = state.comstr_start;






reply via email to

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