Recognize identical() ConstantValues as equal.

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 .
This commit is contained in:
Stephen Adams 2016-03-08 17:18:27 -08:00
parent 18f46ec2a7
commit d367741ead

View file

@ -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 &&
@ -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;
@ -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;
@ -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;