]> git.eshelyaron.com Git - emacs.git/commitdiff
(c-in-knr-argdecl): Limit number of paren/bracket pairs parsed, to solve
authorAlan Mackenzie <acm@muc.de>
Fri, 7 Mar 2008 22:34:09 +0000 (22:34 +0000)
committerAlan Mackenzie <acm@muc.de>
Fri, 7 Mar 2008 22:34:09 +0000 (22:34 +0000)
performance problem.

lisp/progmodes/cc-engine.el

index 6ccd41a164c3037decfa33ae32bd98a221cab94b..2007f8ef91974c825c14f6d80cd986a4369f1ae6 100644 (file)
@@ -6336,7 +6336,8 @@ comment at the start of cc-engine.el for more info."
       ;; the searchable range.
       (let* ((macro-start (c-query-macro-start))
             (lim (max (or lim (point-min)) (or macro-start (point-min))))
-            before-lparen after-rparen)
+            before-lparen after-rparen
+            (pp-count-out 20)) ; Max number of paren/brace constructs before we give up
        (narrow-to-region lim (c-point 'eol))
 
        ;; Search backwards for the defun's argument list.  We give up if we
@@ -6358,7 +6359,8 @@ comment at the start of cc-engine.el for more info."
        ;; {
 
        (catch 'knr
-         (while t ; go round one paren/bracket construct each time round.
+         (while (> pp-count-out 0) ; go back one paren/bracket pair each time.
+           (setq pp-count-out (1- pp-count-out))
            (c-syntactic-skip-backward "^)]}")
            (cond ((eq (char-before) ?\))
                   (setq after-rparen (point)))