simpler regexp for js identifiers

non identifier chars in \u00a1-\uffff range are errors anyway
   so they can be highlighted either as operator or as identifier
   using this instead of detailed unicode regexps reduces parse time
   by ~3x, and gives the same result for any valid js
This commit is contained in:
nightwing 2012-08-24 09:55:12 +04:00
commit e92ed07a19

View file

@ -93,11 +93,7 @@ var JavaScriptHighlightRules = function() {
);
// TODO: Unicode escape sequences
var identifierRe = "[" + unicode.packages.L + "\\$_]["
+ unicode.packages.L
+ unicode.packages.Mn + unicode.packages.Mc
+ unicode.packages.Nd
+ unicode.packages.Pc + "\\$_]*\\b";
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\d\\$_\u00a1-\uffff]*\\b";
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
"u[0-9a-fA-F]{4}|" + // unicode