From 73bd3fd2383d90165a53366f11ed059afb3f97a0 Mon Sep 17 00:00:00 2001 From: tomlu Date: Wed, 13 Sep 2017 19:38:11 +0200 Subject: Remove Path instance from Artifact. In the long run it would be good to remove the Path class altogether. PiperOrigin-RevId: 168560355 --- .../java/com/google/devtools/build/lib/actions/Artifact.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/actions') diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java index 971601436e..5847445c1f 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java +++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java @@ -156,7 +156,6 @@ public class Artifact public static final Predicate MIDDLEMAN_FILTER = input -> !input.isMiddlemanArtifact(); private final int hashCode; - private final Path path; private final Root root; private final PathFragment execPath; private final PathFragment rootRelativePath; @@ -190,7 +189,6 @@ public class Artifact + " (root: " + root + ")"); } this.hashCode = path.hashCode(); - this.path = path; this.root = root; this.execPath = execPath; // These two lines establish the invariant that @@ -246,7 +244,7 @@ public class Artifact } public final Path getPath() { - return path; + return root.getPath().getRelative(rootRelativePath); } public boolean hasParent() { @@ -589,10 +587,9 @@ public class Artifact if (!(other instanceof Artifact)) { return false; } - // We don't bother to check root in the equivalence relation, because we - // assume that no root is an ancestor of another one. Artifact that = (Artifact) other; - return Objects.equals(this.path, that.path); + return Objects.equals(this.rootRelativePath, that.rootRelativePath) + && Objects.equals(this.root, that.root); } @Override @@ -626,7 +623,7 @@ public class Artifact return "[" + root + "]" + rootRelativePath; } else { // Derived Artifact: path and root are under execRoot - PathFragment execRoot = trimTail(path.asFragment(), execPath); + PathFragment execRoot = trimTail(getPath().asFragment(), execPath); return "[[" + execRoot + "]" + root.getPath().asFragment().relativeTo(execRoot) + "]" + rootRelativePath; } -- cgit v1.2.3