aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/vfs/Path.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-04-20 19:20:37 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-04-21 10:59:33 +0000
commitbaeba8b286f9fef8c5a0dcd55086855626f27735 (patch)
treefb3a066c0dcdfa9ff41e289453a89670ed5ee01c /src/main/java/com/google/devtools/build/lib/vfs/Path.java
parent31a4a1f4c413a2bd88fe40593e3dc8f4a5b41bda (diff)
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
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs/Path.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/Path.java3
1 files changed, 3 insertions, 0 deletions
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 e20247d551..ffd41d2c15 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 @@ public class Path implements Comparable<Path>, Serializable {
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);
}