diff options
author | nharmata <nharmata@google.com> | 2017-04-04 17:11:39 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2017-04-05 15:18:20 +0200 |
commit | b4060b6e53944a7c3bdc5e62b288e7293a87652a (patch) | |
tree | 59b0f1f3d3e8e99412e060bb98b5a37fe90d9b6e /src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.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/cpp/CppHelper.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java index a94d10ea6d..41afb816ff 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java @@ -283,7 +283,7 @@ public class CppHelper { * Returns the directory where object files are created. */ public static PathFragment getObjDirectory(Label ruleLabel) { - return AnalysisUtils.getUniqueDirectory(ruleLabel, new PathFragment("_objs")); + return AnalysisUtils.getUniqueDirectory(ruleLabel, PathFragment.create("_objs")); } /** @@ -360,7 +360,7 @@ public class CppHelper { BuildConfiguration config, LinkTargetType linkType, String linkedArtifactNameSuffix) { - PathFragment name = new PathFragment(ruleContext.getLabel().getName()); + PathFragment name = PathFragment.create(ruleContext.getLabel().getName()); if (linkType != LinkTargetType.EXECUTABLE) { name = name.replaceName( "lib" + name.getBaseName() + linkedArtifactNameSuffix + linkType.getExtension()); |