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/rules/nativedeps/NativeDepsHelper.java | |
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/rules/nativedeps/NativeDepsHelper.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java b/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java index 6ec5120849..dc9e9e8ca7 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java @@ -107,7 +107,7 @@ public abstract class NativeDepsHelper { return null; } - PathFragment labelName = new PathFragment(ruleContext.getLabel().getName()); + PathFragment labelName = PathFragment.create(ruleContext.getLabel().getName()); String libraryIdentifier = ruleContext.getUniqueDirectory(ANDROID_UNIQUE_DIR) .getRelative(labelName.replaceName("lib" + labelName.getBaseName())) .getPathString(); @@ -260,11 +260,11 @@ public abstract class NativeDepsHelper { * symlink for the native library for the specified rule. */ private static PathFragment getRuntimeLibraryPath(RuleContext ruleContext, Artifact lib) { - PathFragment relativePath = new PathFragment(ruleContext.getLabel().getName()); + PathFragment relativePath = PathFragment.create(ruleContext.getLabel().getName()); PathFragment libParentDir = relativePath.replaceName(lib.getExecPath().getParentDirectory().getBaseName()); String libName = lib.getExecPath().getBaseName(); - return new PathFragment(libParentDir, new PathFragment(libName)); + return PathFragment.create(libParentDir, PathFragment.create(libName)); } /** @@ -305,6 +305,6 @@ public abstract class NativeDepsHelper { for (String feature : features) { fp.addString(feature); } - return new PathFragment("_nativedeps/" + fp.hexDigestAndReset()); + return PathFragment.create("_nativedeps/" + fp.hexDigestAndReset()); } } |