]> git.eshelyaron.com Git - emacs.git/commit
CC Mode: introduce a new cache for brace structures. This fixes bug #45248
authorAlan Mackenzie <acm@muc.de>
Thu, 24 Dec 2020 11:29:27 +0000 (11:29 +0000)
committerAlan Mackenzie <acm@muc.de>
Thu, 24 Dec 2020 11:29:27 +0000 (11:29 +0000)
commit3096437593ca6d1ea07809f7d0e2198705f20e55
tree013eeb294c23ba48540962c1cdc9a7ab39bd24c0
parentccb3efffc5a41353abb6ae223a7dcff1ea20e5fb
CC Mode: introduce a new cache for brace structures.  This fixes bug #45248

Also fix three infinite loops.  The new cache accelerates backward searches
for struct beginnings in c-looking-at-or-maybe-in-bracelist.

* lisp/progmodes/cc-engine.el (c-beginning-of-statement-1): In the final loop
over unary operators, add a check (> (point) lim) to avoid certain infinite
loops.
(c-beginning-of-decl-1): In the first loop add a similar check on point and
lim.
(c-laomib-loop): New function extracted from
c-looking-at-or-maybe-in-bracelist.
(c-laomib-cache): New buffer local variable.
(c-laomib-get-cache, c-laomib-put-cache, c-laomib-fix-elt)
(c-laomib-invalidate-cache): New functions which implement the cache.
(c-looking-at-or-maybe-in-bracelist): Replace two invocations of
c-go-up-list-backwards with calls to c-parse-state.  Extract the new function
c-laomib-loop.  Insert code which calls c-laomib-loop minimally, with the help
of the new cache.

* lisp/progmodes/cc-mode.el (c-basic-common-init): Initialise the new cach
(at mode start).
(c-before-change): Invalidate the new cache.
(c-fl-decl-start): Add an extra check (> (point) bod-lim) to prevent looping.
Determine the enclosing brace to pass as arguments to
c-looking-at-or-maybe-in-bracelist.
lisp/progmodes/cc-engine.el
lisp/progmodes/cc-mode.el