diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-04-11 13:05:36 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-04-11 13:05:36 +0200 |
commit | 32897fd1983f853fcf51f73d4b4115dc39a7a598 (patch) | |
tree | 9e1f12765e61b365479946e3211d86aa5ef3b88c /helm-buffers.el | |
parent | c442e39115a069b13f1cc950c9ab458338f55f4b (diff) |
Memoize fuzzy pattern in buffers.
* helm-buffers.el (helm-buffer--memo-hash): New hash table.
(helm-buffer--memo-pattern): New.
(helm-buffer--match-pattern): Use it.
Diffstat (limited to 'helm-buffers.el')
-rw-r--r-- | helm-buffers.el | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/helm-buffers.el b/helm-buffers.el index 012cd1af..e8b05e1d 100644 --- a/helm-buffers.el +++ b/helm-buffers.el @@ -499,12 +499,18 @@ i.e same color." (and pos pos-test) (and neg neg-test (not neg-test))))))) +(defvar helm-buffer--memo-hash (make-hash-table :test 'equal)) +(defun helm-buffer--memo-pattern (pattern) + (or (gethash pattern helm-buffer--memo-hash) + (puthash pattern (helm--mapconcat-pattern pattern) + helm-buffer--memo-hash))) + (defun helm-buffer--match-pattern (pattern candidate &optional nofuzzy) (let ((bfn (if (and helm-buffers-fuzzy-matching (not nofuzzy) (not helm-migemo-mode) (not (string-match "\\`\\^" pattern))) - #'helm--mapconcat-pattern + #'helm-buffer--memo-pattern #'identity)) (mfn (if helm-migemo-mode #'helm-mm-migemo-string-match #'string-match))) |