Migration: add collection element caching to MigrationResolutionHooksImpl.
This should make the fix builder faster, since TypedLiteralResolver has to query the elements of various collections multiple times. Change-Id: If49317b8e095b49b693e8a4885914a631efd6d2e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131844 Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
3f02e7d749
commit
fa02e7d8cd
@@ -192,6 +192,8 @@ class FixBuilder {
|
||||
class MigrationResolutionHooksImpl implements MigrationResolutionHooks {
|
||||
final FixBuilder _fixBuilder;
|
||||
|
||||
final Expando<List<CollectionElement>> _collectionElements = Expando();
|
||||
|
||||
FlowAnalysis<AstNode, Statement, Expression, PromotableElement, DartType>
|
||||
_flowAnalysis;
|
||||
|
||||
@@ -240,7 +242,7 @@ class MigrationResolutionHooksImpl implements MigrationResolutionHooks {
|
||||
|
||||
@override
|
||||
List<CollectionElement> getListElements(ListLiteral node) {
|
||||
return node.elements
|
||||
return _collectionElements[node] ??= node.elements
|
||||
.map(_transformCollectionElement)
|
||||
.where((e) => e != null)
|
||||
.toList();
|
||||
@@ -254,7 +256,7 @@ class MigrationResolutionHooksImpl implements MigrationResolutionHooks {
|
||||
|
||||
@override
|
||||
List<CollectionElement> getSetOrMapElements(SetOrMapLiteral node) {
|
||||
return node.elements
|
||||
return _collectionElements[node] ??= node.elements
|
||||
.map(_transformCollectionElement)
|
||||
.where((e) => e != null)
|
||||
.toList();
|
||||
|
||||
Reference in New Issue
Block a user