branch: elpa/nix-mode
commit e744c602fdcb505021d36f00238a1c09ab6f8bc2
Author: Jakub Piecuch <[email protected]>
Commit: Jakub Piecuch <[email protected]>

    Replace regex operations with faster alternatives in the lexer.
---
 nix-mode.el | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/nix-mode.el b/nix-mode.el
index c08ca91e24..ffdbcb1477 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -401,9 +401,7 @@ STRING-TYPE type of string based off of Emacs syntax table 
types"
        (right " -bseqskip- ")
        (left " -fseqskip- "))))))
 
-(defconst nix-smie--symbols-re
-  (regexp-opt '(":" "->" "||" "&&" "==" "!=" "<" "<=" ">" ">="
-     "//" "-" "+" "*" "/" "++" "?" "=" "," ";" "!")))
+(defconst nix-smie--symbol-chars ":->|&=!</-+*?,;!")
 
 (defconst nix-smie--infix-symbols-re
   (regexp-opt '(":" "->" "||" "&&" "==" "!=" "<" "<=" ">" ">="
@@ -516,8 +514,8 @@ STRING-TYPE type of string based off of Emacs syntax table 
types"
        (point)
        (progn
          (or (/= 0 (skip-syntax-forward "'w_"))
-             (and (looking-at nix-smie--symbols-re)
-                  (goto-char (match-end 0))))
+             (/= 0 (skip-chars-forward nix-smie--symbol-chars))
+             (skip-syntax-forward ".'"))
          (point)))))
 
 (defun nix-smie--forward-token ()
@@ -536,8 +534,8 @@ STRING-TYPE type of string based off of Emacs syntax table 
types"
        (point)
        (progn
          (or (/= 0 (skip-syntax-backward "'w_"))
-             (and (looking-back nix-smie--symbols-re (- (point) 2) t)
-                  (goto-char (match-beginning 0))))
+             (/= 0 (skip-chars-backward nix-smie--symbol-chars))
+             (skip-syntax-backward ".'"))
          (point)))))
 
 (defun nix-smie--backward-token ()

Reply via email to