emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master b1b7f9d 032/271: Optimize tokens by connecting tail ends.


From: Jackson Ray Hamilton
Subject: [elpa] master b1b7f9d 032/271: Optimize tokens by connecting tail ends.
Date: Thu, 05 Feb 2015 18:29:33 +0000

branch: master
commit b1b7f9d53d82e5fedf7dd8db5a416bc861c99f45
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Optimize tokens by connecting tail ends.
---
 jslint.js    |    2 +-
 tokenizer.js |   33 +++++++++++++++++++++++++++------
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/jslint.js b/jslint.js
index 338ee0e..5f5828c 100644
--- a/jslint.js
+++ b/jslint.js
@@ -172,7 +172,7 @@
 // For example:
 
 /*jslint
-    evil: true, nomen: true, regexp: true, todo: true
+    evil: true, node: true, nomen: true, regexp: true, todo: true
 */
 
 // The current option set is
diff --git a/tokenizer.js b/tokenizer.js
index a684123..2f60dab 100644
--- a/tokenizer.js
+++ b/tokenizer.js
@@ -61,7 +61,20 @@ process.stdin.on('readable', function () {
 });
 
 process.stdin.on('end', function () {
-    var data, globals, totals, out, i, tokens, length, cap, token, origin, 
level, total;
+
+    var data,
+        globals,
+        totals,
+        out,
+        i,
+        tokens,
+        length,
+        cap,
+        token,
+        origin,
+        level,
+        total,
+        previous;
 
     // Generate a syntax tree for the input.
     JSLINT(whole, jslintOptions);
@@ -101,11 +114,19 @@ process.stdin.on('end', function () {
         }
         total = totals[token.line - 1];
 
-        out.push({
-            l: level,
-            s: cap(total + token.from),
-            e: cap(total + token.thru)
-        });
+        previous = out[out.length - 1];
+
+        if (previous &&
+                previous.l === level &&
+                previous.e === (total + token.from)) {
+            previous.e = cap(total + token.thru);
+        } else {
+            out.push({
+                l: level,
+                s: cap(total + token.from),
+                e: cap(total + token.thru)
+            });
+        }
 
         i += 1;
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]