Skip to content

Commit 392db5a

Browse files
CitoIvanGoncharov
authored andcommitted
Simplify parser, avoid extra function call (#2073)
1 parent ce8b4cd commit 392db5a

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/language/parser.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ class Parser {
433433
return {
434434
kind: Kind.ARGUMENT,
435435
name: this.parseName(),
436-
value: (this.expectToken(TokenKind.COLON), this.parseConstValue()),
436+
value: (this.expectToken(TokenKind.COLON), this.parseValueLiteral(true)),
437437
loc: this.loc(start),
438438
};
439439
}
@@ -597,22 +597,14 @@ class Parser {
597597
};
598598
}
599599

600-
parseConstValue(): ValueNode {
601-
return this.parseValueLiteral(true);
602-
}
603-
604-
parseValueValue(): ValueNode {
605-
return this.parseValueLiteral(false);
606-
}
607-
608600
/**
609601
* ListValue[Const] :
610602
* - [ ]
611603
* - [ Value[?Const]+ ]
612604
*/
613605
parseList(isConst: boolean): ListValueNode {
614606
const start = this._lexer.token;
615-
const item = isConst ? this.parseConstValue : this.parseValueValue;
607+
const item = () => this.parseValueLiteral(isConst);
616608
return {
617609
kind: Kind.LIST,
618610
values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R),
@@ -949,7 +941,7 @@ class Parser {
949941
const type = this.parseTypeReference();
950942
let defaultValue;
951943
if (this.expectOptionalToken(TokenKind.EQUALS)) {
952-
defaultValue = this.parseConstValue();
944+
defaultValue = this.parseValueLiteral(true);
953945
}
954946
const directives = this.parseDirectives(true);
955947
return {

0 commit comments

Comments
 (0)