[Pkg-javascript-commits] [node-acorn-jsx] 37/484: rearrange isIdentifierStart

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:01 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-acorn-jsx.

commit c20cdbf8fcf2bf71ee2ac4d94db3e1f55e745b06
Author: abraidwood <alistair_braidwood at yahoo.co.uk>
Date:   Wed Oct 17 07:23:15 2012 +0100

    rearrange isIdentifierStart
---
 acorn.js   | 8 +++++---
 index.html | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/acorn.js b/acorn.js
index 993d134..0e11d85 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 051c15f..6463591 100644
--- a/index.html
+++ b/index.html
@@ -200,9 +200,11 @@ code point above 128.</p>             </td>             <td class="code">
   <span class="kd">var</span> <span class="nx">nonASCIIidentifierStart</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s2">"["</span> <span class="o">+</span> <span class="nx">nonASCIIidentifierStartChars</span> <span class="o">+</span> <span class="s2">"]"</span><span class="p">);</span>
   <span class="kd">var</span> <span class="nx">nonASCIIidentifier</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s2">"["</span> <span class="o">+</span> <span class="nx">nonASCIIidentifierStartChars</span> <span class="o">+</span> <span class="nx">nonASCIIidentifierChars</span> <span class="o">+</span> <span class="s2">"]"</span><span class="p">);</span></pre></div>             </td>        [...]
 line break). Used to count lines.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">var</span> <span class="nx">lineBreak</span> <span class="o">=</span> <span class="sr">/\r\n|[\n\r\u2028\u2029]/g</span><span class="p">;</span></pre></div>             </td>           </tr>                               <tr id="section-47">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" hr [...]
-    <span class="k">return</span> <span class="p">(</span><span class="nx">code</span> <span class="o">>=</span> <span class="mi">65</span> <span class="o">&&</span> <span class="nx">code</span> <span class="o"><=</span> <span class="mi">90</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="nx">code</span> <span class="o">>=</span> <span class="mi">97</span> <span class="o">&&</span> <span class="nx">code</span> <span cl [...]
-      <span class="nx">code</span> <span class="o">===</span> <span class="mi">36</span> <span class="o">||</span> <span class="nx">code</span> <span class="o">===</span> <span class="mi">95</span> <span class="o">||</span>
-      <span class="p">(</span><span class="nx">code</span> <span class="o">>=</span> <span class="mh">0xaa</span> <span class="o">&&</span> <span class="nx">nonASCIIidentifierStart</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nb">String</span><span class="p">.</span><span class="nx">fromCharCode</span><span class="p">(</span><span class="nx">code</span><span class="p">)));</span>
+    <span class="k">if</span> <span class="p">(</span><span class="nx">code</span> <span class="o"><</span> <span class="mi">65</span><span class="p">)</span> <span class="k">return</span> <span class="nx">code</span> <span class="o">===</span> <span class="mi">36</span><span class="p">;</span>
+    <span class="k">if</span> <span class="p">(</span><span class="nx">code</span> <span class="o"><</span> <span class="mi">91</span><span class="p">)</span> <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
+    <span class="k">if</span> <span class="p">(</span><span class="nx">code</span> <span class="o"><</span> <span class="mi">97</span><span class="p">)</span> <span class="k">return</span> <span class="nx">code</span> <span class="o">===</span> <span class="mi">95</span><span class="p">;</span>
+    <span class="k">if</span> <span class="p">(</span><span class="nx">code</span> <span class="o"><</span> <span class="mi">123</span><span class="p">)</span><span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
+    <span class="k">return</span> <span class="nx">code</span> <span class="o">>=</span> <span class="mh">0xaa</span> <span class="o">&&</span> <span class="nx">nonASCIIidentifierStart</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nb">String</span><span class="p">.</span><span class="nx">fromCharCode</span><span class="p">(</span><span class="nx">code</span><span class="p">));</span>
   <span class="p">}</span></pre></div>             </td>           </tr>                               <tr id="section-48">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-48">¶</a>               </div>               <p>Test whether a given character is part of an identifier.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kd">function</span> <span class=" [...]
     <span class="k">return</span> <span class="p">((</span><span class="nx">ch</span> <span class="o">>=</span> <span class="s2">"a"</span> <span class="o">&&</span> <span class="nx">ch</span> <span class="o"><=</span> <span class="s2">"z"</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="nx">ch</span> <span class="o">>=</span> <span class="s2">"A"</span> <span class="o">&&</span> <span cla [...]
             <span class="p">(</span><span class="nx">ch</span> <span class="o">>=</span> <span class="s2">"0"</span> <span class="o">&&</span> <span class="nx">ch</span> <span class="o"><=</span> <span class="s2">"9"</span><span class="p">)</span> <span class="o">||</span> <span class="nx">ch</span> <span class="o">===</span> <span class="s2">"$"</span> <span class="o">||</span> <span class="nx">ch</span> <span class="o">===</span> <span class= [...]

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git



More information about the Pkg-javascript-commits mailing list