[Pkg-javascript-commits] [node-acorn-jsx] 435/484: Optimize JSX text reading.
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:21:07 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 95479ab6aa69bb4162500700ccebe359028aef70
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Tue Jan 27 16:51:45 2015 +0200
Optimize JSX text reading.
---
acorn.js | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/acorn.js b/acorn.js
index 1507882..2447814 100644
--- a/acorn.js
+++ b/acorn.js
@@ -1534,35 +1534,43 @@
// Reads inline JSX contents token.
function readJSXToken() {
- var out = "", start = tokPos;
+ var out = "", chunkStart = tokPos;
for (;;) {
if (tokPos >= inputLen) raise(tokStart, "Unterminated JSX contents");
var ch = input.charCodeAt(tokPos);
switch (ch) {
case 123: // '{'
case 60: // '<'
- if (tokPos === start) {
+ if (tokPos === tokStart) {
return getTokenFromCode(ch);
}
+ out += input.slice(chunkStart, tokPos);
return finishToken(_jsxText, out);
case 38: // '&'
+ out += input.slice(chunkStart, tokPos);
out += readJSXEntity();
+ chunkStart = tokPos;
break;
default:
- ++tokPos;
if (isNewLine(ch)) {
+ out += input.slice(chunkStart, tokPos);
+ ++tokPos;
if (ch === 13 && input.charCodeAt(tokPos) === 10) {
++tokPos;
- ch = 10;
+ out += "\n";
+ } else {
+ out += String.fromCharCode(ch);
}
if (options.locations) {
++tokCurLine;
tokLineStart = tokPos;
}
+ chunkStart = tokPos;
+ } else {
+ ++tokPos;
}
- out += String.fromCharCode(ch);
}
}
}
--
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