Skip to content

Commit c8d515c

Browse files
committed
Don't compute curLine when locations are off
FIX: Avoid computing the start line in `parseExpressionAt` when locations aren't used. Issue #1448
1 parent a7bd3cd commit c8d515c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

acorn/src/state.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ export class Parser {
3232
// Set up token state
3333

3434
// The current position of the tokenizer in the input.
35+
this.curLine = 1
3536
if (startPos) {
3637
this.pos = startPos
3738
this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1
38-
this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length
39+
if (this.options.locations)
40+
this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length
3941
} else {
4042
this.pos = this.lineStart = 0
41-
this.curLine = 1
4243
}
4344

4445
// Properties of the current token:

0 commit comments

Comments
 (0)