Skip to content

Commit 85e0160

Browse files
committed
context keys: parser: remove unnecessary bounds check
1 parent 5416584 commit 85e0160

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/vs/platform/contextkey/common/contextkey.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class ParseError extends Error { }
311311
export class Parser {
312312

313313
private _tokens: Token[] = [];
314-
private _current = 0;
314+
private _current = 0; // invariant: 0 <= this._current < this._tokens.length ; any incrementation of this value must first call `_isAtEnd`
315315
private _parsingErrors: string[] = [];
316316
private _scanner = new Scanner();
317317

@@ -575,9 +575,12 @@ export class Parser {
575575
}
576576

577577
private _check(type: TokenType) {
578-
return !this._isAtEnd() && this._peek().type === type;
578+
return this._peek().type === type;
579579
}
580580

581+
/*
582+
Careful: the function doesn't check array bounds.
583+
*/
581584
private _peek() {
582585
return this._tokens[this._current];
583586
}

0 commit comments

Comments
 (0)