branch: master commit ebc0b9996d6701df7ccee1d7e5adee00ed8c0760 Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Add rollover font lock optimization. --- scripts/tokenizer.js | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/tokenizer.js b/scripts/tokenizer.js index b7b3268..14f4ed5 100644 --- a/scripts/tokenizer.js +++ b/scripts/tokenizer.js @@ -34,7 +34,8 @@ process.stdin.on('readable', function () { }); process.stdin.on('end', function () { - var data, totals, out, i, tokens, length, token, origin, level, total; + var data, totals, out, i, tokens, length, token, origin, level, total, + previous; // Generate a syntax tree for the input. JSLINT(whole); @@ -72,11 +73,17 @@ process.stdin.on('end', function () { } total = totals[token.line - 1]; - out.push({ - l: level, - s: total + token.from, - e: total + token.thru - }); + previous = out[out.length - 1]; + + if (previous && previous.l === level) { + previous.e = total + token.thru; + } else { + out.push({ + l: level, + s: total + token.from, + e: total + token.thru + }); + } i += 1; }