diff options
author | 2017-04-04 17:11:39 +0000 | |
---|---|---|
committer | 2017-04-05 15:18:20 +0200 | |
commit | b4060b6e53944a7c3bdc5e62b288e7293a87652a (patch) | |
tree | 59b0f1f3d3e8e99412e060bb98b5a37fe90d9b6e /src/test/java/com/google/devtools/build/lib/analysis/util | |
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/analysis/util')
3 files changed, 8 insertions, 8 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java index f821e467a7..eb25ec3318 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestUtil.java @@ -277,10 +277,10 @@ public final class AnalysisTestUtil { ArtifactFactory artifactFactory, ArtifactOwner artifactOwner, Supplier<UUID> buildId, String workspaceName) { Artifact stableStatus = artifactFactory.getDerivedArtifact( - new PathFragment("build-info.txt"), + PathFragment.create("build-info.txt"), directories.getBuildDataDirectory(workspaceName), artifactOwner); Artifact volatileStatus = artifactFactory.getConstantMetadataArtifact( - new PathFragment("build-changelist.txt"), + PathFragment.create("build-changelist.txt"), directories.getBuildDataDirectory(workspaceName), artifactOwner); return new DummyWorkspaceStatusAction(key, stableStatus, volatileStatus); } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java index d8acbcffc9..184ba7d6fc 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestBase.java @@ -107,7 +107,7 @@ public abstract class BuildViewTestBase extends AnalysisTestCase { Path symlinkcycleBuildFile = scratch.file("symlinkcycle/BUILD", "sh_library(name = 'cycle', srcs = glob(['*.sh']))"); Path dirPath = symlinkcycleBuildFile.getParentDirectory(); - dirPath.getRelative("foo.sh").createSymbolicLink(new PathFragment("foo.sh")); + dirPath.getRelative("foo.sh").createSymbolicLink(PathFragment.create("foo.sh")); scratch.file("okaypkg/BUILD", "sh_library(name = 'transitively-a-cycle',", " srcs = ['//symlinkcycle:cycle'])"); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java index 576a312c85..47a59a4d86 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java @@ -773,7 +773,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { } skyframeExecutor.invalidateFilesUnderPathForTesting( reporter, - new ModifiedFileSet.Builder().modify(new PathFragment(buildFilePathString)).build(), + new ModifiedFileSet.Builder().modify(PathFragment.create(buildFilePathString)).build(), rootDirectory); return (Rule) getTarget("//" + packageName + ":" + ruleName); } @@ -924,7 +924,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { } protected Artifact getSourceArtifact(String name) { - return getSourceArtifact(new PathFragment(name), Root.asSourceRoot(rootDirectory)); + return getSourceArtifact(PathFragment.create(name), Root.asSourceRoot(rootDirectory)); } /** @@ -959,7 +959,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { * used instead. */ protected Artifact getBinArtifactWithNoOwner(String rootRelativePath) { - return getDerivedArtifact(new PathFragment(rootRelativePath), + return getDerivedArtifact(PathFragment.create(rootRelativePath), targetConfig.getBinDirectory(RepositoryName.MAIN), ActionsTestUtil.NULL_ARTIFACT_OWNER); } @@ -1037,7 +1037,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { * #getGenfilesArtifact(String, ArtifactOwner)} or its convenience methods should be used instead. */ protected Artifact getGenfilesArtifactWithNoOwner(String rootRelativePath) { - return getDerivedArtifact(new PathFragment(rootRelativePath), + return getDerivedArtifact(PathFragment.create(rootRelativePath), targetConfig.getGenfilesDirectory(RepositoryName.MAIN), ActionsTestUtil.NULL_ARTIFACT_OWNER); } @@ -1150,7 +1150,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { * @param owner the artifact's owner. */ protected Artifact getSharedArtifact(String rootRelativePath, ConfiguredTarget owner) { - return getDerivedArtifact(new PathFragment(rootRelativePath), + return getDerivedArtifact(PathFragment.create(rootRelativePath), targetConfig.getBinDirectory(RepositoryName.MAIN), new ConfiguredTargetKey(owner)); } |