mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:00:09 +00:00
Reland "Use identical as shortcut in equality checks"
This is a reland of 4b5893f9cf
Nothing has changed, the revert was accidental.
Original change's description:
> Use identical as shortcut in equality checks
>
> These equality checks are showing up in a profile-run of the type flow analysis.
> For this particular benchmark, time went down ~10% from ~32.2s to ~29.5s.
>
> Change-Id: I158f1db0d0816aa347f89ae0228f7a9a5158318f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115203
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Change-Id: Ia7bdf790f48eab2060f51328a50eaff153483203
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115216
Reviewed-by: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
This commit is contained in:
parent
d2e99c4935
commit
af9e298391
|
@ -111,9 +111,10 @@ abstract class _Invocation extends _DependencyTracker
|
|||
// are cached in _InvocationsCache using selector and args as a key.
|
||||
@override
|
||||
bool operator ==(other) =>
|
||||
identical(this, other) ||
|
||||
(other is _Invocation) &&
|
||||
(this.selector == other.selector) &&
|
||||
(this.args == other.args);
|
||||
(this.selector == other.selector) &&
|
||||
(this.args == other.args);
|
||||
|
||||
@override
|
||||
int get hashCode => (selector.hashCode ^ args.hashCode + 31) & kHashMask;
|
||||
|
@ -920,7 +921,9 @@ class _ClassData extends _DependencyTracker implements ClassId<_ClassData> {
|
|||
int get hashCode => _id;
|
||||
|
||||
@override
|
||||
bool operator ==(other) => (other is _ClassData) && (this._id == other._id);
|
||||
bool operator ==(other) =>
|
||||
identical(this, other) ||
|
||||
(other is _ClassData) && (this._id == other._id);
|
||||
|
||||
@override
|
||||
int compareTo(_ClassData other) => this._id.compareTo(other._id);
|
||||
|
|
|
@ -38,7 +38,8 @@ abstract class Selector {
|
|||
int get hashCode => callKind.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(other) => other is Selector && other.callKind == callKind;
|
||||
bool operator ==(other) =>
|
||||
identical(this, other) || other is Selector && other.callKind == callKind;
|
||||
|
||||
/// Static approximation of Dart return type.
|
||||
DartType get staticReturnType {
|
||||
|
@ -107,6 +108,7 @@ class DirectSelector extends Selector {
|
|||
|
||||
@override
|
||||
bool operator ==(other) =>
|
||||
identical(this, other) ||
|
||||
other is DirectSelector && super == (other) && other.member == member;
|
||||
|
||||
@override
|
||||
|
@ -125,6 +127,7 @@ class InterfaceSelector extends Selector {
|
|||
|
||||
@override
|
||||
bool operator ==(other) =>
|
||||
identical(this, other) ||
|
||||
other is InterfaceSelector && super == (other) && other.member == member;
|
||||
|
||||
@override
|
||||
|
@ -140,7 +143,8 @@ class VirtualSelector extends InterfaceSelector {
|
|||
int get hashCode => (super.hashCode + 37) & kHashMask;
|
||||
|
||||
@override
|
||||
bool operator ==(other) => other is VirtualSelector && super == (other);
|
||||
bool operator ==(other) =>
|
||||
identical(this, other) || other is VirtualSelector && super == (other);
|
||||
|
||||
@override
|
||||
String toString() => 'virtual ${_callKindPrefix}[$member]';
|
||||
|
@ -163,6 +167,7 @@ class DynamicSelector extends Selector {
|
|||
|
||||
@override
|
||||
bool operator ==(other) =>
|
||||
identical(this, other) ||
|
||||
other is DynamicSelector && super == (other) && other.name == name;
|
||||
|
||||
@override
|
||||
|
@ -207,6 +212,7 @@ class Args<T extends TypeExpr> {
|
|||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (other is Args<T> &&
|
||||
(this.values.length == other.values.length) &&
|
||||
(this.names.length == other.names.length)) {
|
||||
|
|
|
@ -215,6 +215,7 @@ class NullableType extends Type {
|
|||
|
||||
@override
|
||||
bool operator ==(other) =>
|
||||
identical(this, other) ||
|
||||
(other is NullableType) && (this.baseType == other.baseType);
|
||||
|
||||
@override
|
||||
|
@ -329,6 +330,7 @@ class SetType extends Type {
|
|||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
if (identical(this, other)) return true;
|
||||
if ((other is SetType) && (types.length == other.types.length)) {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (types[i] != other.types[i]) {
|
||||
|
@ -502,6 +504,7 @@ class ConeType extends Type {
|
|||
|
||||
@override
|
||||
bool operator ==(other) =>
|
||||
identical(this, other) ||
|
||||
(other is ConeType) && (this.dartType == other.dartType);
|
||||
|
||||
@override
|
||||
|
@ -704,6 +707,7 @@ class ConcreteType extends Type implements Comparable<ConcreteType> {
|
|||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (other is ConcreteType) {
|
||||
if (this.classId != other.classId ||
|
||||
this.numImmediateTypeArgs != other.numImmediateTypeArgs) {
|
||||
|
@ -870,6 +874,7 @@ class RuntimeType extends Type {
|
|||
|
||||
@override
|
||||
operator ==(other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (other is RuntimeType) {
|
||||
if (other._type != _type) return false;
|
||||
assertx(numImmediateTypeArgs == other.numImmediateTypeArgs);
|
||||
|
|
Loading…
Reference in a new issue