[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-mode 9cf0ad4ee5 1/7: Reduce (over)use of markers (
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-mode 9cf0ad4ee5 1/7: Reduce (over)use of markers (#1751) |
Date: |
Fri, 3 Mar 2023 13:01:19 -0500 (EST) |
branch: elpa/haskell-mode
commit 9cf0ad4ee5f019d10ca4bcc56a14de65280c6964
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Mattias EngdegÄrd <mattiase@acm.org>
Reduce (over)use of markers (#1751)
The parser used by the font-lock code created a massive amount of
markers; try to reduce it as far as possible since they make some
operations expensive as long as they are in the buffer. Even orphaned
markers stay until next GC.
Read match data as integers instead of markers, and don't create new
markers when setting the match data. This should work just fine as
long as the buffer isn't changed during the match data lifetime, which
appears reasonable.
---
haskell-lexeme.el | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/haskell-lexeme.el b/haskell-lexeme.el
index 622f53f278..5b1998f3bb 100644
--- a/haskell-lexeme.el
+++ b/haskell-lexeme.el
@@ -98,7 +98,7 @@ Returns:
After successful 'qid or 'qsym match (match-string 1) will return
the unqualified part (if any)."
(let ((begin (point))
- (match-data-old (match-data)))
+ (match-data-old (match-data t)))
(save-excursion
(while (looking-at (concat haskell-lexeme-modid "\\."))
(goto-char (match-end 0)))
@@ -138,7 +138,7 @@ When match is successful, match-data will contain:
(match-text 2) - whole qualified identifier
(match-text 3) - unqualified part of identifier
(match-text 4) - closing backtick"
- (let ((match-data-old (match-data))
+ (let ((match-data-old (match-data t))
first-backtick-start
last-backtick-start
qid-start
@@ -159,15 +159,12 @@ When match is successful, match-data will contain:
(when (looking-at "`")
(setq last-backtick-start (match-beginning 0))
(set-match-data
- (mapcar
- (lambda (p)
- (set-marker (make-marker) p))
- (list
- first-backtick-start (1+ last-backtick-start)
- first-backtick-start (1+ first-backtick-start)
- qid-start id-end
- id-start id-end
- last-backtick-start (1+ last-backtick-start))))
+ (list
+ first-backtick-start (1+ last-backtick-start)
+ first-backtick-start (1+ first-backtick-start)
+ qid-start id-end
+ id-start id-end
+ last-backtick-start (1+ last-backtick-start)))
(setq result t)))))
(unless result
(set-match-data match-data-old))
@@ -370,7 +367,7 @@ Regexp has subgroup expressions:
Note that this function excludes 'e', 't', 'd', 'p' as quoter
names according to Template Haskell specification."
- (let ((match-data-old (match-data)))
+ (let ((match-data-old (match-data t)))
(if (and
(looking-at (rx-to-string `(: "[" (optional "$")
(regexp
,haskell-lexeme-modid-opt-prefix)
@@ -383,9 +380,9 @@ names according to Template Haskell specification."
;; note that quasi quote syntax does not have any escaping
;; mechanism and if not closed it will span til lthe end of buffer
(goto-char (match-end 0))
- (let ((match-data (match-data))
+ (let ((match-data (match-data t))
(match-data-2 (and (re-search-forward "|]" nil t)
- (match-data))))
+ (match-data t))))
(if match-data-2
(set-match-data
(list
@@ -472,20 +469,20 @@ See `haskell-lexeme-classify-by-first-char' for details."
(> (skip-chars-forward "\n") 0))))
(let
((case-fold-search nil)
- (point (point-marker)))
+ (point (point)))
(or
(and
(equal (string-to-syntax "<")
(get-char-property (point) 'syntax-table))
(progn
- (set-match-data (list point (set-marker (make-marker)
(line-end-position))))
+ (set-match-data (list point (line-end-position)))
'literate-comment))
(and (looking-at "\n")
'newline)
(and (looking-at "{-")
(save-excursion
(forward-comment 1)
- (set-match-data (list point (point-marker)))
+ (set-match-data (list point (point)))
'nested-comment))
(and (haskell-lexeme-looking-at-char-literal)
'char)
@@ -499,7 +496,7 @@ See `haskell-lexeme-classify-by-first-char' for details."
(if (save-match-data
(string-match "\\`---*\\'" (match-string-no-properties 0)))
(progn
- (set-match-data (list point (set-marker (make-marker)
(line-end-position))))
+ (set-match-data (list point (line-end-position)))
'comment)
'qsymid))
(and (looking-at haskell-lexeme-number)
- [nongnu] elpa/haskell-mode updated (a34ccdc54b -> 810b08e317), ELPA Syncer, 2023/03/03
- [nongnu] elpa/haskell-mode abce84fef3 6/7: Merge branch 'master' into cull-markers, ELPA Syncer, 2023/03/03
- [nongnu] elpa/haskell-mode 810b08e317 7/7: Merge pull request #1760 from mattiase/cull-markers, ELPA Syncer, 2023/03/03
- [nongnu] elpa/haskell-mode 310d8907c5 4/7: Update install-nix-action, ELPA Syncer, 2023/03/03
- [nongnu] elpa/haskell-mode 9cf0ad4ee5 1/7: Reduce (over)use of markers (#1751),
ELPA Syncer <=
- [nongnu] elpa/haskell-mode 6aa9473951 2/7: Don't use user-reserved "C-c e" keybinding in haskell-doc-mode, ELPA Syncer, 2023/03/03
- [nongnu] elpa/haskell-mode 922f730cbd 5/7: Merge pull request #1802 from haskell/haskell-doc-mode-tidyup, ELPA Syncer, 2023/03/03
- [nongnu] elpa/haskell-mode e80a5d4749 3/7: Use eldoc consistently in haskell-doc-mode instead of reimplementing it, ELPA Syncer, 2023/03/03