[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 4aeb058 078/495: add cache to go-previous-line-has
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 4aeb058 078/495: add cache to go-previous-line-has-dangling-op-p |
Date: |
Sat, 7 Aug 2021 09:04:47 -0400 (EDT) |
branch: elpa/go-mode
commit 4aeb058e1830855f7f6ae5bbc97cdbf69e985a13
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
add cache to go-previous-line-has-dangling-op-p
---
go-mode.el | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index 3713eb2..a9130e3 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -27,6 +27,7 @@
(defconst go-constants '("nil" "true" "false" "iota"))
(defconst go-type-name-regexp (concat "\\(?:[*(]\\)*\\(?:"
go-identifier-regexp "\\.\\)?\\(" go-identifier-regexp "\\)"))
+(defvar go-dangling-cache)
(defgroup go nil
"Major mode for editing Go code"
@@ -156,10 +157,14 @@ some syntax analysis.")
(/= start-pos (point))))
(defun go-previous-line-has-dangling-op-p ()
- (save-excursion
- (beginning-of-line)
- (go--backward-irrelevant t)
- (looking-back go-dangling-operators-regexp)))
+ (let* ((cur-line (count-lines (point-min) (point)))
+ (val (gethash cur-line go-dangling-cache 'nope)))
+ (if (equal val 'nope)
+ (save-excursion
+ (beginning-of-line)
+ (go--backward-irrelevant t)
+ (puthash cur-line (looking-back go-dangling-operators-regexp)
go-dangling-cache))
+ val)))
(defun go-goto-opening-parenthesis (&optional char)
(let ((start-nesting (go-paren-level)) group)
@@ -280,6 +285,8 @@ functions, and some types. It also provides indentation
that is
(set (make-local-variable 'beginning-of-defun-function)
'go-beginning-of-defun)
(set (make-local-variable 'end-of-defun-function) 'go-end-of-defun)
+ (set (make-local-variable 'go-dangling-cache) #s(hash-table test eql))
+ (add-to-list 'before-change-functions (lambda (x y) (setq go-dangling-cache
#s(hash-table test eql))))
(setq imenu-generic-expression
- [nongnu] elpa/go-mode 4371669 029/495: Merge branch 'feature/remove_unused_imports', (continued)
- [nongnu] elpa/go-mode 4371669 029/495: Merge branch 'feature/remove_unused_imports', ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode cd13093 034/495: use inhibit-read-only instead of toggle-read-only, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b6dfdd4 037/495: Closes gh-5, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9dbdf22 041/495: Do not skip over strings when checking for dangling operator, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 95c9519 049/495: when searching for anchor for indentation, do not limit search to one line, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 399393a 057/495: remove dead code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ee10287 059/495: Revert "Fix indentation for code after multi-line function signature", ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 79d5860 073/495: improve fontification, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 49b9355 074/495: do not change indentation if in multiline string, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 522543f 077/495: replace several defuns with macros, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4aeb058 078/495: add cache to go-previous-line-has-dangling-op-p,
ELPA Syncer <=
- [nongnu] elpa/go-mode 438f671 082/495: update documentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c2366b2 084/495: formatting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode fb9ab02 087/495: buffer-file-truename is an *abbreviated* truename, so use file-truename instead., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 745c437 092/495: style fixes, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode c833b77 094/495: Fix cache invalidation for dangling operator cache, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 87c8b6e 096/495: do not use dangling op cache when buffer is narrowed, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8e19ae5 097/495: add some documentation, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b5960fe 099/495: nicer messages in gofmt, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 939d630 100/495: style fixes, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 47b3928 102/495: disable read-only on error buffer before trying to write to it, ELPA Syncer, 2021/08/07