diff options
author | tomlu <tomlu@google.com> | 2017-09-13 19:38:11 +0200 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2017-09-14 18:42:10 +0200 |
commit | 73bd3fd2383d90165a53366f11ed059afb3f97a0 (patch) | |
tree | a9196cf2264f9faf81a9754b4a87c5561dd1e38e /src/main/java/com/google/devtools/build/lib/actions/Artifact.java | |
parent | a92d37752105dcb870d881551b5fb29200f4dadd (diff) |
Remove Path instance from Artifact.
In the long run it would be good to remove the Path class altogether.
PiperOrigin-RevId: 168560355
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/Artifact.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/actions/Artifact.java | 11 |
1 files changed, 4 insertions, 7 deletions
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<Artifact> 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; } |