From 3d0f85d6165cc276eccff7262befb412d810d496 Mon Sep 17 00:00:00 2001 From: Alistair Braidwood Date: Fri, 21 Dec 2012 08:29:44 +0000 Subject: [PATCH] line_loc type for v8 perf --- acorn.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/acorn.js b/acorn.js index 1ccd4d51dc..176920400f 100644 --- a/acorn.js +++ b/acorn.js @@ -394,13 +394,18 @@ return match ? match.index + match[0].length : input.length + 1; } + var line_loc_t = function() { + this.line = tokCurLine; + this.column = tokPos - tokLineStart; + } + function curLineLoc() { while (tokLineStartNext <= tokPos) { ++tokCurLine; tokLineStart = tokLineStartNext; tokLineStartNext = nextLineStart(); } - return {line: tokCurLine, column: tokPos - tokLineStart}; + return new line_loc_t(); } // Reset the token state. Used at the start of a parse. @@ -920,7 +925,7 @@ } if (options.locations) { node.loc = new node_loc_t(); - node.loc.start = other.loc.start;//{start: other.loc.start, end: null, source: other.loc.source}; + node.loc.start = other.loc.start; } if (options.ranges) node.range = [other.range[0], 0];