diff options
author | 2017-04-04 17:11:39 +0000 | |
---|---|---|
committer | 2017-04-05 15:18:20 +0200 | |
commit | b4060b6e53944a7c3bdc5e62b288e7293a87652a (patch) | |
tree | 59b0f1f3d3e8e99412e060bb98b5a37fe90d9b6e /src/main/java/com/google/devtools/build/lib/exec | |
parent | 3ac77cb94a4cf1bd1993a97fe79f2005b2b1a711 (diff) |
Refactor all ctor callsites of PathFragment to instead call a static 'create' method.
This paves the way for changing PathFragment to e.g. an abstract class with multiple subclasses. This way we can split out the windows-specific stuff into one of these concrete classes, making the code more readable and also saving memory (since the shallow heap size of the NonWindowsPathFragment subclass will hopefully be smaller than that of the current PathFragment).
This also lets us pursue gc churn optimizations. We can now do interning in PathFragment#create and can also get rid of unnecessary intermediate PathFragment allocations.
RELNOTES: None
PiperOrigin-RevId: 152145768
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/exec')
3 files changed, 4 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java b/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java index 4099a8ad54..ec93068c1d 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java @@ -130,7 +130,7 @@ public class SingleBuildFileCache implements ActionInputFileCache { */ private String fullPath(ActionInput input) { String relPath = input.getExecPathString(); - return new PathFragment(relPath).isAbsolute() ? relPath : new File(cwd, relPath).getPath(); + return PathFragment.create(relPath).isAbsolute() ? relPath : new File(cwd, relPath).getPath(); } /** Container class for caching I/O around ActionInputs. */ diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java index f32d238243..351f8c7e10 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java @@ -147,7 +147,7 @@ public class SpawnInputExpander { PathFragment location; int pos = line.indexOf(' '); if (pos == -1) { - location = new PathFragment(line); + location = PathFragment.create(line); artifact = EMPTY_FILE; } else { String targetPath = line.substring(pos + 1); @@ -156,7 +156,7 @@ public class SpawnInputExpander { } artifact = targetPath.isEmpty() ? EMPTY_FILE : ActionInputHelper.fromPath(targetPath); - location = new PathFragment(line.substring(0, pos)); + location = PathFragment.create(line.substring(0, pos)); if (!workspaceName.isEmpty()) { if (!location.getSegment(0).equals(workspaceName)) { throw new IOException( diff --git a/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java index 9a99031dd8..0a29b9f89d 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java @@ -127,7 +127,7 @@ public abstract class TestStrategy implements TestActionContext { } } - public static final PathFragment TEST_TMP_ROOT = new PathFragment("_tmp"); + public static final PathFragment TEST_TMP_ROOT = PathFragment.create("_tmp"); // Used for generating unique temporary directory names. Contains the next numeric index for every // executable base name. |