[cfe] Use identical in subtype check
This improves the subtype check by ~27%. Using subtype_measure.dart the test result was: TTestResult[significant: -27.74% +/- 2.03% (-34846.20 +/- 2548.23) (at least -32297.97)] Change-Id: I908fe8807f7b265c59f6e5f83e3e8a444eb11743 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387965 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
01a26f9022
commit
a128973291
@@ -525,7 +525,8 @@ sealed class DartType extends Node implements SharedType {
|
||||
R accept1<R, A>(DartTypeVisitor1<R, A> v, A arg);
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => equals(other, null);
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) || equals(other, null);
|
||||
|
||||
/// The nullability declared on the type.
|
||||
///
|
||||
@@ -1747,7 +1748,8 @@ class NamedType extends Node
|
||||
DartType get typeShared => type;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => equals(other, null);
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) || equals(other, null);
|
||||
|
||||
bool equals(Object other, Assumptions? assumptions) {
|
||||
return other is NamedType &&
|
||||
@@ -2237,9 +2239,6 @@ class StructuralParameterType extends DartType {
|
||||
@override
|
||||
void visitChildren(Visitor v) {}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => equals(other, null);
|
||||
|
||||
@override
|
||||
bool equals(Object other, Assumptions? assumptions) {
|
||||
if (identical(this, other)) {
|
||||
|
||||
@@ -63,6 +63,7 @@ class Types with StandardBounds {
|
||||
}
|
||||
|
||||
IsSubtypeOf performSubtypeCheck(DartType s, DartType t) {
|
||||
if (s == t) return const IsSubtypeOf.success();
|
||||
switch ((s, t)) {
|
||||
// TODO(johnniwinther,cstefantsova): Ensure complete handling of
|
||||
// InvalidType in the subtype relation.
|
||||
|
||||
Reference in New Issue
Block a user