Don't do a deep comparison in ArtifactNestedSetKey.
The deep comparison does cost a lot of CPU time and
avoids creating duplicate objects only in rare cases.
RELNOTES: None
@@ -46,10 +46,6 @@ public class ArtifactNestedSetKey implements SkyKey {
@Override
public int hashCode() {
- if (rawChildren instanceof Object[]) {
- // Warning: Ignoring Order
- return Arrays.hashCode((Object[]) rawChildren);
- }
return rawChildren.hashCode();
}
@@ -68,12 +64,13 @@ public class ArtifactNestedSetKey implements SkyKey {
return true;
}
- if (rawChildren instanceof Object[] && theirRawChildren instanceof Object[]) {
- return Arrays.equals((Object[]) rawChildren, (Object[]) theirRawChildren);
- }
+ if (rawChildren instanceof Artifact && theirRawChildren instanceof Artifact) {
return rawChildren.equals(theirRawChildren);
}
+ return false;
+ }
+
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
