[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/xr ee8ac4a 08/12: Minor looking-at optimisation
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/xr ee8ac4a 08/12: Minor looking-at optimisation |
Date: |
Mon, 30 Nov 2020 04:32:25 -0500 (EST) |
branch: externals/xr
commit ee8ac4a7b6ef7c9c3bb797b67e4797f17579be20
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Minor looking-at optimisation
Don't use `looking-at` for matching a single literal character; it is
much more expensive than using `following-char`, and consumes precious
regexp cache.
---
xr.el | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/xr.el b/xr.el
index 0f899fe..0941309 100644
--- a/xr.el
+++ b/xr.el
@@ -111,11 +111,11 @@
(xr--escape-string (match-string 0) nil)))))
(goto-char (match-end 0)))
;; Initial ]
- ((looking-at "]")
+ ((eq (following-char) ?\])
(push (vector ?\] ?\] (point)) intervals)
(forward-char 1)))
- (while (not (looking-at "]"))
+ (while (not (eq (following-char) ?\]))
(cond
;; character class
((looking-at (rx "[:" (group (* (not (any ":")))) ":]"))
@@ -153,7 +153,7 @@
"Two-character range `%s'"
(xr--escape-string (match-string 0) nil))))
(goto-char (match-end 0))))
- ((looking-at (rx eos))
+ ((eobp)
(error "Unterminated character alternative"))
;; plain character (including ^ or -)
(t
@@ -509,7 +509,7 @@ like (* (* X) ... (* X))."
(let ((item-start (point)))
(cond
;; ^ - only special at beginning of sequence
- ((looking-at (rx "^"))
+ ((eq (following-char) ?^)
(forward-char 1)
(if (null sequence)
(progn
@@ -522,7 +522,7 @@ like (* (* X) ... (* X))."
(push "^" sequence)))
;; $ - only special at end of sequence
- ((looking-at (rx "$"))
+ ((eq (following-char) ?$)
(forward-char 1)
(if (looking-at (rx (or "\\|" "\\)" eos)))
(progn
@@ -718,12 +718,12 @@ like (* (* X) ... (* X))."
sequence))
;; not-newline
- ((looking-at (rx "."))
- (goto-char (match-end 0))
+ ((eq (following-char) ?.)
+ (forward-char)
;; Assume that .* etc is intended.
(when (and (eq purpose 'file)
(not (looking-at (rx (any "?*+")))))
- (xr--report warnings (match-beginning 0)
+ (xr--report warnings (1- (point))
(format-message
"Possibly unescaped `.' in file-matching regexp")))
(push 'nonl sequence))
@@ -1438,7 +1438,7 @@ A-SETS and B-SETS are arguments to `any'."
(xr--report warnings (point)
(format-message "Suspect skip set framed in `[...]'")))
- (let ((negated (looking-at (rx "^")))
+ (let ((negated (eq (following-char) ?^))
(start-pos (point))
(ranges nil)
(classes nil))
- [elpa] externals/xr 77ad0d6 04/12: syntax and category always match non-empty, for bos/eos anchor check, (continued)
- [elpa] externals/xr 77ad0d6 04/12: syntax and category always match non-empty, for bos/eos anchor check, Mattias Engdegård, 2020/11/30
- [elpa] externals/xr 32546a7 10/12: Fix character alternative duplication removal, Mattias Engdegård, 2020/11/30
- [elpa] externals/xr a655991 02/12: Use correct text quoting in message about . in file-matching regexp, Mattias Engdegård, 2020/11/30
- [elpa] externals/xr 461dce1 03/12: Remove dead function xr--matches-nonempty-only-p, Mattias Engdegård, 2020/11/30
- [elpa] externals/xr 6f2e516 09/12: Comment update, Mattias Engdegård, 2020/11/30
- [elpa] externals/xr a444d8c 11/12: Explain why we are not using rx in one place, Mattias Engdegård, 2020/11/30
- [elpa] externals/xr 17d7599 05/12: Improved test coverage with some omitted cases, Mattias Engdegård, 2020/11/30
- [elpa] externals/xr 9b69cc7 06/12: Run automatic tests on Emacs 27.1, Mattias Engdegård, 2020/11/30
- [elpa] externals/xr 2a82e8d 12/12: Increment version to 1.20, Mattias Engdegård, 2020/11/30
- [elpa] externals/xr c7c861f 07/12: Describe diagnostics in README (taken from relint/README), Mattias Engdegård, 2020/11/30
- [elpa] externals/xr ee8ac4a 08/12: Minor looking-at optimisation,
Mattias Engdegård <=