Skip to content

Commit c49bb12

Browse files
author
Ben Segall
committed
Cache (regexp-opt rust-special-types 'symbols) in rust-is-lt-char-operator
regexp-opt is generally intended to be cached, and the extra GC was causing noticeable lag when typing sometimes.
1 parent c0e3878 commit c49bb12

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rust-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@
378378
;; newer Emacs versions, but will work on Emacs 23.)
379379
(defun regexp-opt-symbols (words)
380380
(concat "\\_<" (regexp-opt words t) "\\_>"))
381+
(defconst rust-re-special-types (regexp-opt-symbols rust-special-types))
381382

382383
(defvar rust-mode-font-lock-keywords
383384
(append
@@ -851,7 +852,7 @@
851852
(or
852853
;; The special types can't take type param lists, so a < after one is
853854
;; always an operator
854-
(looking-at (regexp-opt rust-special-types 'symbols))
855+
(looking-at rust-re-special-types)
855856

856857
(rust-is-in-expression-context 'ident)))
857858

0 commit comments

Comments
 (0)