branch: externals/hotfuzz
commit 61f9ff60c87767d2c2870b97e2aa41da04488c7c
Author: Axel Forsman <[email protected]>
Commit: Axel Forsman <[email protected]>
Anchor match pattern
Speeds up matching since the regex engine has to do less work to throw
away any non-matches.
---
hotfuzz.el | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hotfuzz.el b/hotfuzz.el
index 83adb3b7f7..160fe31e20 100644
--- a/hotfuzz.el
+++ b/hotfuzz.el
@@ -74,9 +74,10 @@ j - the column"
"Filter CANDIDATES that match STRING and sort by the match scores."
(if (or (> (length string) hotfuzz--max-match-len) (string-empty-p string))
candidates
- (let ((re (mapconcat (lambda (char) (format "[^%1$s]*%1$s"
- (regexp-quote (char-to-string
char))))
- string ""))
+ (let ((re (concat "^" (mapconcat (lambda (char)
+ (format "[^%1$s]*%1$s"
+ (regexp-quote (char-to-string
char))))
+ string "")))
(case-fold-search t))
(sort (cl-loop for x in candidates if (string-match re x) do
(setq x (copy-sequence x))