[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>
This commit is contained in:
Mayank Patke
2025-04-03 14:06:04 -07:00
committed by Commit Queue
parent de3f423952
commit 8cb4d3c981
@@ -43,25 +43,6 @@ part 'type_mask.dart';
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 @@ class CommonMasks with AbstractValueDomain {
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 @@ class CommonMasks with AbstractValueDomain {
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(