Skip to content

Commit bd0fa88

Browse files
jensjohaCommit Queue
authored andcommitted
[parser] Inline first part of _tryRewriteNewToIdentifier
pkg/analyzer/lib/src/dart/ast/ast.dart: JIT (tokens per microsecond): 1.3425% +/- 1.0526% (0.33 +/- 0.26) (24.64 -> 24.98) AOT (tokens per microsecond): 1.1587% +/- 0.7860% (0.38 +/- 0.26) (32.45 -> 32.83) Benchmarker (AOT): ``` instructions:u: -1.9853% +/- 0.0000% (-439384607.18 +/- 518.28) (22131742462.46 -> 21692357855.28) ``` pkg/front_end/lib/src/type_inference/inference_visitor.dart: JIT (tokens per microsecond): 1.4245% +/- 0.7653% (0.28 +/- 0.15) (19.90 -> 20.18) AOT (tokens per microsecond): 1.7105% +/- 0.8890% (0.45 +/- 0.23) (26.25 -> 26.70) Benchmarker (AOT): ``` msec task-clock:u: -1.3071% +/- 0.8717% (-30.64 +/- 20.44) (2344.53 -> 2313.89) page-faults:u: -0.0097% +/- 0.0084% (-0.96 +/- 0.84) (9945.42 -> 9944.46) cycles:u: -1.4071% +/- 0.8701% (-143026423.34 +/- 88437058.62) (10164329405.06 -> 10021302981.72) instructions:u: -2.2650% +/- 0.0000% (-488077498.12 +/- 960.50) (21548947043.38 -> 21060869545.26) branch-misses:u: -3.7824% +/- 3.3800% (-1316798.12 +/- 1176704.41) (34813893.88 -> 33497095.76) seconds time elapsed: -1.3039% +/- 0.8711% (-0.03 +/- 0.02) (2.35 -> 2.32) seconds user: -1.3918% +/- 0.8962% (-0.03 +/- 0.02) (2.32 -> 2.29) ``` Change-Id: Ide847121b70db8564f1ea7f9d77ea5d63da1d6ac Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443081 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent d337376 commit bd0fa88

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,25 +3703,30 @@ class Parser {
37033703
/// context that permits `new` to be treated as an identifier, rewrites the
37043704
/// `new` token to an identifier token, and reports the rewritten token to the
37053705
/// listener. Otherwise does nothing.
3706+
@pragma("vm:prefer-inline")
37063707
void _tryRewriteNewToIdentifier(Token token, IdentifierContext context) {
37073708
if (!context.allowsNewAsIdentifier) return;
3709+
_tryRewriteNewToIdentifierImpl(token);
3710+
}
3711+
3712+
void _tryRewriteNewToIdentifierImpl(Token token) {
37083713
Token identifier = token.next!;
3709-
if (identifier.kind == KEYWORD_TOKEN) {
3710-
final String? value = token.next!.stringValue;
3711-
if (value == 'new') {
3712-
// `new` after `.` is treated as an identifier so that it can represent
3713-
// an unnamed constructor.
3714-
Token replacementToken = rewriter.replaceTokenFollowing(
3715-
token,
3716-
new StringToken(
3717-
TokenType.IDENTIFIER,
3718-
identifier.lexeme,
3719-
token.next!.charOffset,
3720-
),
3721-
);
3722-
listener.handleNewAsIdentifier(replacementToken);
3723-
}
3724-
}
3714+
if (identifier.kind != KEYWORD_TOKEN) return;
3715+
3716+
final String? value = identifier.stringValue;
3717+
if (value != 'new') return;
3718+
3719+
// `new` after `.` is treated as an identifier so that it can represent
3720+
// an unnamed constructor.
3721+
Token replacementToken = rewriter.replaceTokenFollowing(
3722+
token,
3723+
new StringToken(
3724+
TokenType.IDENTIFIER,
3725+
identifier.lexeme,
3726+
identifier.charOffset,
3727+
),
3728+
);
3729+
listener.handleNewAsIdentifier(replacementToken);
37253730
}
37263731

37273732
/// Parse a simple identifier at the given [token], and return the identifier

0 commit comments

Comments
 (0)