Skip to content

Commit 86b6584

Browse files
jensjohaCommit Queue
authored andcommitted
[parser] Manually inline 'isNextIdentifier'
pkg/analyzer/lib/src/dart/ast/ast.dart: JIT (tokens per microsecond): 2.1064% +/- 1.6771% (0.44 +/- 0.35) (20.97 -> 21.42) AOT (tokens per microsecond): No change. Benchmarker (AOT): ``` msec task-clock:u: -1.2559% +/- 0.6202% (-35.75 +/- 17.65) (2846.58 -> 2810.83) cycles:u: -1.3051% +/- 0.6113% (-161347113.30 +/- 75579075.11) (12362747585.00 -> 12201400471.70) instructions:u: -0.6245% +/- 0.0000% (-169931728.50 +/- 1390.09) (27212753414.40 -> 27042821685.90) seconds time elapsed: -1.2465% +/- 0.6111% (-0.04 +/- 0.02) (2.85 -> 2.81) seconds user: -1.3083% +/- 0.7709% (-0.04 +/- 0.02) (2.83 -> 2.79) ``` pkg/front_end/lib/src/type_inference/inference_visitor.dart: JIT (tokens per microsecond): No change. AOT (tokens per microsecond): No change. Benchmarker (AOT): ``` instructions:u: -0.9284% +/- 0.0000% (-279155451.00 +/- 502.76) (30068900827.90 -> 29789745376.90) ``` Change-Id: I70eaae39d156f77e5e451a8592f6f3dab2da3d67 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439780 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 752b760 commit 86b6584

File tree

706 files changed

+8
-2995
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

706 files changed

+8
-2995
lines changed

pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3718,10 +3718,6 @@ class Parser {
37183718
}
37193719
}
37203720

3721-
/// Checks whether the next token is (directly) an identifier. If this returns
3722-
/// true a call to [ensureIdentifier] will return the next token.
3723-
bool isNextIdentifier(Token token) => token.next?.kind == IDENTIFIER_TOKEN;
3724-
37253721
/// Parse a simple identifier at the given [token], and return the identifier
37263722
/// that was parsed.
37273723
///
@@ -8285,8 +8281,10 @@ class Parser {
82858281

82868282
TypeParamOrArgInfo? potentialTypeArg;
82878283

8288-
if (isNextIdentifier(newKeyword)) {
8289-
Token identifier = newKeyword.next!;
8284+
Token next = newKeyword.next!;
8285+
8286+
if (next.kind == IDENTIFIER_TOKEN) {
8287+
Token identifier = next;
82908288
String value = identifier.lexeme;
82918289
if ((value == "Map" || value == "Set") &&
82928290
!identifier.next!.isA(TokenType.PERIOD)) {
@@ -8336,7 +8334,7 @@ class Parser {
83368334
// parseConstructorReference.
83378335
// Do special recovery for literal maps/set/list erroneously prepended
83388336
// with 'new'.
8339-
Token notIdentifier = newKeyword.next!;
8337+
Token notIdentifier = next;
83408338
String value = notIdentifier.lexeme;
83418339
if (value == "<") {
83428340
potentialTypeArg = computeTypeParamOrArg(newKeyword);
@@ -8739,8 +8737,9 @@ class Parser {
87398737
// send an `handleIdentifier` if we end up recovering.
87408738
TypeParamOrArgInfo? potentialTypeArg;
87418739
Token? afterToken;
8742-
if (isNextIdentifier(token)) {
8743-
Token identifier = token.next!;
8740+
Token next = token.next!;
8741+
if (next.kind == IDENTIFIER_TOKEN) {
8742+
Token identifier = next;
87448743
String value = identifier.lexeme;
87458744
if (value == "Map" || value == "Set") {
87468745
potentialTypeArg = computeTypeParamOrArg(identifier);

pkg/front_end/parser_testcases/also-nnbd/issue_39326.dart.intertwined.expect

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ parseUnit(main)
5757
parsePrimary(;, expression, ConstantPatternContext.none)
5858
parseSendOrFunctionLiteral(;, expression, ConstantPatternContext.none)
5959
parseSend(;, expression, ConstantPatternContext.none)
60-
isNextIdentifier(;)
6160
ensureIdentifier(;, expression)
6261
listener: handleIdentifier(c, expression)
6362
listener: handleNoTypeArguments(?.)

pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional.dart.intertwined.expect

Lines changed: 0 additions & 30 deletions
Large diffs are not rendered by default.

pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_2.dart.intertwined.expect

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ parseUnit(f)
6363
parsePrimary(return, expression, ConstantPatternContext.none)
6464
parseSendOrFunctionLiteral(return, expression, ConstantPatternContext.none)
6565
parseSend(return, expression, ConstantPatternContext.none)
66-
isNextIdentifier(return)
6766
ensureIdentifier(return, expression)
6867
listener: handleIdentifier(a, expression)
6968
listener: handleNoTypeArguments(?)
@@ -83,7 +82,6 @@ parseUnit(f)
8382
parseSendOrFunctionLiteral([, expression, ConstantPatternContext.none)
8483
looksLikeFunctionBody(])
8584
parseSend([, expression, ConstantPatternContext.none)
86-
isNextIdentifier([)
8785
ensureIdentifier([, expression)
8886
parseArgumentsOpt(b)
8987
parseArguments(b)
@@ -116,7 +114,6 @@ parseUnit(f)
116114
parseSendOrFunctionLiteral([, expression, ConstantPatternContext.none)
117115
looksLikeFunctionBody(])
118116
parseSend([, expression, ConstantPatternContext.none)
119-
isNextIdentifier([)
120117
ensureIdentifier([, expression)
121118
listener: handleIdentifier(b, expression)
122119
listener: handleNoTypeArguments(()

pkg/front_end/parser_testcases/also-nnbd/issue_40267_conditional_3.dart.intertwined.expect

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ parseUnit(f)
5656
parsePrimary(return, expression, ConstantPatternContext.none)
5757
parseSendOrFunctionLiteral(return, expression, ConstantPatternContext.none)
5858
parseSend(return, expression, ConstantPatternContext.none)
59-
isNextIdentifier(return)
6059
ensureIdentifier(return, expression)
6160
listener: handleIdentifier(a, expression)
6261
listener: handleNoTypeArguments(!=)
@@ -81,7 +80,6 @@ parseUnit(f)
8180
parsePrimary([, expression, ConstantPatternContext.none)
8281
parseSendOrFunctionLiteral([, expression, ConstantPatternContext.none)
8382
parseSend([, expression, ConstantPatternContext.none)
84-
isNextIdentifier([)
8583
ensureIdentifier([, expression)
8684
parseArgumentsOpt(a)
8785
parseExpressionWithoutCascade(:)
@@ -106,7 +104,6 @@ parseUnit(f)
106104
parsePrimary([, expression, ConstantPatternContext.none)
107105
parseSendOrFunctionLiteral([, expression, ConstantPatternContext.none)
108106
parseSend([, expression, ConstantPatternContext.none)
109-
isNextIdentifier([)
110107
ensureIdentifier([, expression)
111108
parseArgumentsOpt(a)
112109
parseExpressionWithoutCascade(:)
@@ -132,7 +129,6 @@ parseUnit(f)
132129
parsePrimary([, expression, ConstantPatternContext.none)
133130
parseSendOrFunctionLiteral([, expression, ConstantPatternContext.none)
134131
parseSend([, expression, ConstantPatternContext.none)
135-
isNextIdentifier([)
136132
ensureIdentifier([, expression)
137133
listener: handleIdentifier(a, expression)
138134
listener: handleNoTypeArguments(])

0 commit comments

Comments
 (0)