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/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.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/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java index 2889e324a8..1b38da18d5 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionTest.java @@ -254,8 +254,8 @@ public class CppLinkActionTest extends BuildViewTestCase { @Test public void testComputeKeyNonStatic() throws Exception { final RuleContext ruleContext = createDummyRuleContext(); - final PathFragment exeOutputPath = new PathFragment("dummyRuleContext/output/path"); - final PathFragment dynamicOutputPath = new PathFragment("dummyRuleContext/output/path.so"); + final PathFragment exeOutputPath = PathFragment.create("dummyRuleContext/output/path"); + final PathFragment dynamicOutputPath = PathFragment.create("dummyRuleContext/output/path.so"); final Artifact staticOutputFile = getBinArtifactWithNoOwner(exeOutputPath.getPathString()); final Artifact dynamicOutputFile = getBinArtifactWithNoOwner(dynamicOutputPath.getPathString()); final Artifact oFile = getSourceArtifact("cc/a.o"); @@ -286,7 +286,7 @@ public class CppLinkActionTest extends BuildViewTestCase { builder.setNativeDeps((i & 4) == 0); builder.setUseTestOnlyFlags((i & 8) == 0); builder.setFake((i & 16) == 0); - builder.setRuntimeSolibDir((i & 32) == 0 ? null : new PathFragment("so1")); + builder.setRuntimeSolibDir((i & 32) == 0 ? null : PathFragment.create("so1")); builder.setFeatureConfiguration(featureConfiguration); return builder.build(); @@ -301,8 +301,8 @@ public class CppLinkActionTest extends BuildViewTestCase { @Test public void testComputeKeyStatic() throws Exception { final RuleContext ruleContext = createDummyRuleContext(); - final PathFragment staticOutputPath = new PathFragment("dummyRuleContext/output/path.a"); - final PathFragment dynamicOutputPath = new PathFragment("dummyRuleContext/output/path.so"); + final PathFragment staticOutputPath = PathFragment.create("dummyRuleContext/output/path.a"); + final PathFragment dynamicOutputPath = PathFragment.create("dummyRuleContext/output/path.so"); final Artifact staticOutputFile = getBinArtifactWithNoOwner(staticOutputPath.getPathString()); final Artifact dynamicOutputFile = getBinArtifactWithNoOwner(dynamicOutputPath.getPathString()); final Artifact oFile = getSourceArtifact("cc/a.o"); @@ -336,11 +336,11 @@ public class CppLinkActionTest extends BuildViewTestCase { public void testCommandLineSplitting() throws Exception { RuleContext ruleContext = createDummyRuleContext(); Artifact output = getDerivedArtifact( - new PathFragment("output/path.xyz"), getTargetConfiguration().getBinDirectory( + PathFragment.create("output/path.xyz"), getTargetConfiguration().getBinDirectory( RepositoryName.MAIN), ActionsTestUtil.NULL_ARTIFACT_OWNER); final Artifact outputIfso = getDerivedArtifact( - new PathFragment("output/path.ifso"), getTargetConfiguration().getBinDirectory( + PathFragment.create("output/path.ifso"), getTargetConfiguration().getBinDirectory( RepositoryName.MAIN), ActionsTestUtil.NULL_ARTIFACT_OWNER); CppLinkActionBuilder builder = @@ -432,7 +432,7 @@ public class CppLinkActionTest extends BuildViewTestCase { new CppLinkActionBuilder( ruleContext, new Artifact( - new PathFragment(outputPath), + PathFragment.create(outputPath), getTargetConfiguration() .getBinDirectory(ruleContext.getRule().getRepository())), ruleContext.getConfiguration(), @@ -451,7 +451,7 @@ public class CppLinkActionTest extends BuildViewTestCase { } private CppLinkActionBuilder createLinkBuilder(Link.LinkTargetType type) throws Exception { - PathFragment output = new PathFragment("dummyRuleContext/output/path.a"); + PathFragment output = PathFragment.create("dummyRuleContext/output/path.a"); return createLinkBuilder( type, output.getPathString(), |