[dart2js] Remove _CanonicalizedTypeMaskKey and use record
Since #60419 is fixed by https://github.com/dart-lang/sdk/issues/60419,
we should be able to use record keys again.
Change-Id: I1256d74e80e135b0ba2a38c64c42e0463964baaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419986
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
diff --git a/pkg/compiler/lib/src/inferrer/typemasks/masks.dart b/pkg/compiler/lib/src/inferrer/typemasks/masks.dart
index 8d625fe..bc9bd0c 100644
--- a/pkg/compiler/lib/src/inferrer/typemasks/masks.dart
+++ b/pkg/compiler/lib/src/inferrer/typemasks/masks.dart
@@ -43,25 +43,6 @@
part 'union_type_mask.dart';
part 'value_type_mask.dart';
-// TODO(60419): Go back to using a record as the key when it is no longer slower
-// than using a data class.
-final class _CanonicalizedTypeMaskKey {
- final ClassEntity? _base;
- final _Flags _flags;
-
- const _CanonicalizedTypeMaskKey(this._base, this._flags);
-
- @override
- int get hashCode => Object.hash(_base, _flags);
-
- @override
- bool operator ==(Object other) =>
- identical(this, other) ||
- other is _CanonicalizedTypeMaskKey &&
- _base == other._base &&
- _flags == other._flags;
-}
-
class CommonMasks with AbstractValueDomain {
// TODO(sigmund): once we split out the backend common elements, depend
// directly on those instead.
@@ -75,8 +56,7 @@
final Map<TypeMask, Map<TypeMask, TypeMask>> _intersectionCache = {};
- final Map<_CanonicalizedTypeMaskKey, FlatTypeMask> _canonicalizedTypeMasks =
- {};
+ final Map<(ClassEntity?, _Flags), FlatTypeMask> _canonicalizedTypeMasks = {};
/// Return the cached mask for [base] with the given flags, or calls
/// [createMask] to create the mask and cache it.
@@ -84,10 +64,7 @@
ClassEntity? base,
_Flags flags,
FlatTypeMask Function() createMask,
- ) => _canonicalizedTypeMasks.putIfAbsent(
- _CanonicalizedTypeMaskKey(base, flags),
- createMask,
- );
+ ) => _canonicalizedTypeMasks.putIfAbsent((base, flags), createMask);
@override
late final TypeMask internalTopType = TypeMask.subclass(