Skip to content

Commit

Permalink
Recognize identical() ConstantValues as equal.
Browse files Browse the repository at this point in the history
This fast path is not used when interning ConstantValues but is
beneficial when the ConstantValue is the key of a HashMap.

BUG=
R=sigmund@google.com

Review URL: https://codereview.chromium.org/1777483006 .
  • Loading branch information
rakudrama committed Mar 9, 2016
1 parent 18f46ec commit d367741
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/compiler/lib/src/constants/values.dart
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ class StringConstantValue extends PrimitiveConstantValue {
DartType getType(CoreTypes types) => types.stringType;

bool operator ==(var other) {
if (identical(this, other)) return true;
if (other is !StringConstantValue) return false;
StringConstantValue otherString = other;
return hashCode == otherString.hashCode &&
Expand Down Expand Up @@ -461,6 +462,7 @@ class ListConstantValue extends ObjectConstantValue {
bool get isList => true;

bool operator ==(var other) {
if (identical(this, other)) return true;
if (other is !ListConstantValue) return false;
ListConstantValue otherList = other;
if (hashCode != otherList.hashCode) return false;
Expand Down Expand Up @@ -525,6 +527,7 @@ class MapConstantValue extends ObjectConstantValue {
bool get isMap => true;

bool operator ==(var other) {
if (identical(this, other)) return true;
if (other is !MapConstantValue) return false;
MapConstantValue otherMap = other;
if (hashCode != otherMap.hashCode) return false;
Expand Down Expand Up @@ -661,6 +664,7 @@ class ConstructedConstantValue extends ObjectConstantValue {
bool get isConstructedObject => true;

bool operator ==(var otherVar) {
if (identical(this, otherVar)) return true;
if (otherVar is !ConstructedConstantValue) return false;
ConstructedConstantValue other = otherVar;
if (hashCode != other.hashCode) return false;
Expand Down

0 comments on commit d367741

Please sign in to comment.