Short-circuit Path.equals() with hashcode.
Optimize .equals() by using the hashcode calculated in the constructor to determine if we can short-circuit equals and avoid traversing the parents if the two paths can't be equal.
--
MOS_MIGRATED_REVID=120363376
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/Path.java b/src/main/java/com/google/devtools/build/lib/vfs/Path.java
index e20247d..ffd41d2 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/Path.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/Path.java
@@ -345,6 +345,9 @@
return false;
}
Path otherPath = (Path) other;
+ if (hashCode != otherPath.hashCode) {
+ return false;
+ }
return fileSystem.equals(otherPath.fileSystem) && name.equals(otherPath.name)
&& Objects.equals(parent, otherPath.parent);
}