branch: elpa/go-mode
commit 8ddf0b369cff246d7e14f4592c8c053bda36b2eb
Author: Muir Manders <[email protected]>
Commit: Peter Sanford <[email protected]>
Speed up go-goto-opening-parenthesis
Reimplement to use syntax tables directly rather than
backward-up-list. It is much faster now, and it seems to work the same
for our use case. Certain files are affected more than others. For
example, reindenting golang/src/cmd/internal/obj/x86/avx_optabs.go
went from 19.6s to 5.7s after this change.
I think it is faster because syntax-ppss caches the syntax info,
where backward-up-list calls up-list which calls scan-lists which does
a lot of work every time.
Closes: #283 [via git-merge-pr]
---
go-mode.el | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index 6ccddde..b5575d2 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -66,11 +66,9 @@ Return non-nil if there was a paren to move up to."
;; function's outcome.
;; Silently fail if there's no matching opening parenthesis.
- (condition-case nil
- (progn
- (backward-up-list)
- t)
- (scan-error nil)))
+ (let ((open-char (nth 1 (syntax-ppss))))
+ (when open-char
+ (goto-char open-char))))
(defconst go-dangling-operators-regexp "[^-]-\\|[^+]\\+\\|[/*&><.=|^]")