[dart2js] Modernize allocations in js_model/

Change-Id: If93776e2f556e8d7adfdbe5e3603f7477e0486f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213902
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
Stephen Adams 2021-09-21 00:22:55 +00:00 committed by commit-bot@chromium.org
parent 85a12eac55
commit 048dd185c6
4 changed files with 11 additions and 16 deletions

View file

@ -720,7 +720,7 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
// This is necessary to support when a class implements the same
// supertype in multiple non-conflicting ways, like implementing A<int*>
// and A<int?> or B<Object?> and B<dynamic>.
Set<InterfaceType> canonicalSupertypes = <InterfaceType>{};
Set<InterfaceType> canonicalSupertypes = {};
InterfaceType processSupertype(ir.Supertype supertypeNode) {
supertypeNode = classHierarchy.getClassAsInstanceOf(
@ -898,7 +898,7 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
}
var namedParameters = <String>[];
var requiredNamedParameters = <String>{};
List<DartType> namedParameterTypes = <DartType>[];
List<DartType> namedParameterTypes = [];
List<ir.VariableDeclaration> sortedNamedParameters =
node.namedParameters.toList()..sort((a, b) => a.name.compareTo(b.name));
for (ir.VariableDeclaration variable in sortedNamedParameters) {
@ -1508,8 +1508,7 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
@override
ConstantValue getRequiredSentinelConstantValue() {
return ConstructedConstantValue(
_commonElements.requiredSentinelType, <FieldEntity, ConstantValue>{});
return ConstructedConstantValue(_commonElements.requiredSentinelType, {});
}
@override
@ -1771,7 +1770,7 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
if (info.boxedVariables.isNotEmpty) {
NodeBox box = info.capturedVariablesAccessor;
Map<String, IndexedMember> memberMap = <String, IndexedMember>{};
Map<String, IndexedMember> memberMap = {};
JRecord container = JRecord(member.library, box.name);
BoxLocal boxLocal = BoxLocal(container);
InterfaceType thisType =
@ -1838,7 +1837,7 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
}
String name = _computeClosureName(node);
SourceSpan location = computeSourceSpanFromTreeNode(node);
Map<String, IndexedMember> memberMap = <String, IndexedMember>{};
Map<String, IndexedMember> memberMap = {};
JClass classEntity = JClosureClass(enclosingLibrary, name);
// Create a classData and set up the interfaces and subclass

View file

@ -84,8 +84,7 @@ class JsBackendStrategy implements BackendStrategy {
SourceInformationStrategy sourceInformationStrategy;
/// The generated code as a js AST for compiled methods.
final Map<MemberEntity, js.Expression> generatedCode =
<MemberEntity, js.Expression>{};
final Map<MemberEntity, js.Expression> generatedCode = {};
JsBackendStrategy(this._compiler) {
bool generateSourceMap = _compiler.options.generateSourceMap;
@ -332,7 +331,7 @@ class JsBackendStrategy implements BackendStrategy {
generatedCode[member] = result.code;
}
if (retainDataForTesting) {
codegenImpactsForTesting ??= <MemberEntity, WorldImpact>{};
codegenImpactsForTesting ??= {};
codegenImpactsForTesting[member] = result.impact;
}
WorldImpact worldImpact =

View file

@ -56,8 +56,7 @@ class JsClosedWorld implements JClosedWorld {
final Map<ClassEntity, Set<ClassEntity>> typesImplementedBySubclasses;
final Map<ClassEntity, Map<ClassEntity, bool>> _subtypeCoveredByCache =
<ClassEntity, Map<ClassEntity, bool>>{};
final Map<ClassEntity, Map<ClassEntity, bool>> _subtypeCoveredByCache = {};
// TODO(johnniwinther): Can this be derived from [ClassSet]s?
final Set<ClassEntity> implementedClasses;
@ -277,8 +276,7 @@ class JsClosedWorld implements JClosedWorld {
@override
bool everySubtypeIsSubclassOfOrMixinUseOf(ClassEntity x, ClassEntity y) {
Map<ClassEntity, bool> secondMap =
_subtypeCoveredByCache[x] ??= <ClassEntity, bool>{};
Map<ClassEntity, bool> secondMap = _subtypeCoveredByCache[x] ??= {};
return secondMap[y] ??= classHierarchy.subtypesOf(x).every(
(ClassEntity cls) =>
classHierarchy.isSubclassOf(cls, y) ||

View file

@ -677,7 +677,7 @@ E identity<E>(E element) => element;
Map<K, V2> convertMap<K, V1, V2>(
Map<K, V1> map, K convertKey(K key), V2 convertValue(V1 value)) {
Map<K, V2> newMap = <K, V2>{};
Map<K, V2> newMap = {};
map.forEach((K key, V1 value) {
K newKey = convertKey(key);
V2 newValue = convertValue(value);
@ -771,8 +771,7 @@ class _TypeConverter implements DartTypeVisitor<DartType, _EntityConverter> {
final DartTypes _dartTypes;
final bool allowFreeVariables;
Map<FunctionTypeVariable, FunctionTypeVariable> _functionTypeVariables =
<FunctionTypeVariable, FunctionTypeVariable>{};
Map<FunctionTypeVariable, FunctionTypeVariable> _functionTypeVariables = {};
_TypeConverter(this._dartTypes, {this.allowFreeVariables = false});