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/pkgcache | |
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/pkgcache')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/pkgcache/PathPackageLocator.java | 4 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternResolverUtil.java | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/PathPackageLocator.java b/src/main/java/com/google/devtools/build/lib/pkgcache/PathPackageLocator.java index 3ccbc1db99..30609168f3 100644 --- a/src/main/java/com/google/devtools/build/lib/pkgcache/PathPackageLocator.java +++ b/src/main/java/com/google/devtools/build/lib/pkgcache/PathPackageLocator.java @@ -163,7 +163,7 @@ public class PathPackageLocator implements Serializable { // Replace "%workspace%" with the path of the enclosing workspace directory. pathElement = pathElement.replace(workspaceWildcard, workspace.getPathString()); - PathFragment pathElementFragment = new PathFragment(pathElement); + PathFragment pathElementFragment = PathFragment.create(pathElement); // If the path string started with "%workspace%" or "/", it is already absolute, // so the following line is a no-op. @@ -218,7 +218,7 @@ public class PathPackageLocator implements Serializable { AtomicReference<? extends UnixGlob.FilesystemCalls> cache = UnixGlob.DEFAULT_SYSCALLS_REF; // TODO(bazel-team): correctness in the presence of changes to the location of the WORKSPACE // file. - return getFilePath(new PathFragment("WORKSPACE"), cache); + return getFilePath(PathFragment.create("WORKSPACE"), cache); } private Path getFilePath(PathFragment suffix, diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternResolverUtil.java b/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternResolverUtil.java index d8534caf52..d12b3ac5b5 100644 --- a/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternResolverUtil.java +++ b/src/main/java/com/google/devtools/build/lib/pkgcache/TargetPatternResolverUtil.java @@ -69,7 +69,7 @@ public final class TargetPatternResolverUtil { } public static PathFragment getPathFragment(String pathPrefix) throws TargetParsingException { - PathFragment directory = new PathFragment(pathPrefix); + PathFragment directory = PathFragment.create(pathPrefix); if (directory.containsUplevelReferences()) { throw new TargetParsingException("up-level references are not permitted: '" + directory.getPathString() + "'"); |