Use list comprehensions in *Evaluate._evaluateArguments

As well as being arguably more readable, the toList() method was
running a type check that was showing up as a minor bottleneck in JS
profiles.
This commit is contained in:
Natalie Weizenbaum 2019-07-12 13:22:23 -07:00
parent a8e99e9152
commit 58e9e74b37
2 changed files with 19 additions and 11 deletions

View File

@ -1962,15 +1962,19 @@ class _EvaluateVisitor
{bool trackSpans}) async {
trackSpans ??= _sourceMap;
var positional = (await mapAsync(arguments.positional,
(Expression expression) => expression.accept(this)))
.toList();
var positional = [
for (var expression in arguments.positional) await expression.accept(this)
];
var named = await normalizedMapMapAsync<String, Expression, Value>(
arguments.named,
value: (_, expression) => expression.accept(this));
var positionalNodes =
trackSpans ? arguments.positional.map(_expressionNode).toList() : null;
var positionalNodes = trackSpans
? [
for (var expression in arguments.positional)
_expressionNode(expression)
]
: null;
var namedNodes = trackSpans
? mapMap<String, Expression, String, AstNode>(arguments.named,
value: (_, expression) => _expressionNode(expression))

View File

@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_evaluate.dart.
// See tool/grind/synchronize.dart for details.
//
// Checksum: cae91fd0fcd94fbb45712286a85761d69fef5415
// Checksum: 1685f0e62002cbb13d3d54ea3d5166c4c7f8f678
//
// ignore_for_file: unused_import
@ -1949,14 +1949,18 @@ class _EvaluateVisitor
{bool trackSpans}) {
trackSpans ??= _sourceMap;
var positional = arguments.positional
.map((Expression expression) => expression.accept(this))
.toList();
var positional = [
for (var expression in arguments.positional) expression.accept(this)
];
var named = normalizedMapMap<String, Expression, Value>(arguments.named,
value: (_, expression) => expression.accept(this));
var positionalNodes =
trackSpans ? arguments.positional.map(_expressionNode).toList() : null;
var positionalNodes = trackSpans
? [
for (var expression in arguments.positional)
_expressionNode(expression)
]
: null;
var namedNodes = trackSpans
? mapMap<String, Expression, String, AstNode>(arguments.named,
value: (_, expression) => _expressionNode(expression))