diff --git a/acorn.js b/acorn.js index 993d1341a3..0e11d85ace 100644 --- a/acorn.js +++ b/acorn.js @@ -363,9 +363,11 @@ // Test whether a given character code starts an identifier. function isIdentifierStart(code) { - return (code >= 65 && code <= 90) || (code >= 97 && code <= 122) || - code === 36 || code === 95 || - (code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code))); + if (code < 65) return code === 36; + if (code < 91) return true; + if (code < 97) return code === 95; + if (code < 123)return true; + return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); } // Test whether a given character is part of an identifier. diff --git a/index.html b/index.html index 051c15fcdc..6463591538 100644 --- a/index.html +++ b/index.html @@ -200,9 +200,11 @@ code point above 128.

var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");

Whether a single character denotes a newline.

  var newline = /[\n\r\u2028\u2029]/;

Matches a whole line break (where CRLF is considered a single line break). Used to count lines.

  var lineBreak = /\r\n|[\n\r\u2028\u2029]/g;

Test whether a given character code starts an identifier.

  function isIdentifierStart(code) {
-    return (code >= 65 && code <= 90) || (code >= 97 && code <= 122) ||
-      code === 36 || code === 95 ||
-      (code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)));
+    if (code < 65) return code === 36;
+    if (code < 91) return true;
+    if (code < 97) return code === 95;
+    if (code < 123)return true;
+    return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
   }

Test whether a given character is part of an identifier.

  function isIdentifierChar(ch) {
     return ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") ||
             (ch >= "0" && ch <= "9") || ch === "$" || ch === "_" ||