From: Dmitry Gutov Date: Sun, 6 Jun 2021 21:57:42 +0000 (+0300) Subject: completion-pcm--hilit-commonality: Reuse the match-data cons cells X-Git-Tag: emacs-28.0.90~2175 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6329e70460137e34abbc7590c5892623547f9b26;p=emacs.git completion-pcm--hilit-commonality: Reuse the match-data cons cells * lisp/minibuffer.el (completion-pcm--hilit-commonality): Reuse the match-data cons cells for better performance (bug#48841). --- diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index ec21b7b93b6..d5a0118b7c0 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3484,7 +3484,8 @@ between 0 and 1, and with faces `completions-common-part', (when completions (let* ((re (completion-pcm--pattern->regex pattern 'group)) (point-idx (completion-pcm--pattern-point-idx pattern)) - (case-fold-search completion-ignore-case)) + (case-fold-search completion-ignore-case) + last-md) (mapcar (lambda (str) ;; Don't modify the string itself. @@ -3493,7 +3494,7 @@ between 0 and 1, and with faces `completions-common-part', (error "Internal error: %s does not match %s" re str)) (let* ((pos (if point-idx (match-beginning point-idx) (match-end 0))) (match-end (match-end 0)) - (md (cddr (match-data))) + (md (cddr (setq last-md (match-data t last-md)))) (from 0) (end (length str)) ;; To understand how this works, consider these simple