From e2edf2e141a09c025a958d580c7cac7b57c70d83 Mon Sep 17 00:00:00 2001 From: cpeyser Date: Mon, 22 May 2017 18:23:41 +0200 Subject: Automated g4 rollback of commit c78c947e6a8cbb323304f872a3dcabb989a3d76b. *** Reason for rollback *** Breaks android targets in the nightly - see [] *** Original change description *** Do not retain transitive data in AndroidLocalTestBase. The argument strings and artifacts were both transitive and flattened, causing O(N^2) memory consumption. PiperOrigin-RevId: 156745610 --- .../build/lib/analysis/actions/CommandLine.java | 43 +++------------------- .../lib/analysis/actions/ParamFileHelper.java | 2 +- 2 files changed, 7 insertions(+), 38 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/analysis/actions') diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java index 7bc670569a..1d3e0bebb8 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/CommandLine.java @@ -19,17 +19,10 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander; import com.google.devtools.build.lib.collect.CollectionUtils; +import com.google.devtools.build.lib.util.Preconditions; /** A representation of a list of arguments, often a command executed by {@link SpawnAction}. */ public abstract class CommandLine { - public static final CommandLine EMPTY = - new CommandLine() { - @Override - public Iterable arguments() { - return ImmutableList.of(); - } - }; - /** * Returns the command line. */ @@ -62,42 +55,18 @@ public abstract class CommandLine { * Returns a {@link CommandLine} that is constructed by prepending the {@code executableArgs} to * {@code commandLine}. */ - public static CommandLine concat( - final ImmutableList executableArgs, final CommandLine commandLine) { - if (executableArgs.isEmpty()) { - return commandLine; - } - return new CommandLine() { - @Override - public Iterable arguments() { - return Iterables.concat(executableArgs, commandLine.arguments()); - } - - @Override - public Iterable arguments(ArtifactExpander artifactExpander) { - return Iterables.concat(executableArgs, commandLine.arguments(artifactExpander)); - } - }; - } - - /** - * Returns a {@link CommandLine} that is constructed by appending the {@code args} to {@code - * commandLine}. - */ - public static CommandLine concat( - final CommandLine commandLine, final ImmutableList args) { - if (args.isEmpty()) { - return commandLine; - } + CommandLine prepend(final ImmutableList executableArgs) { + final CommandLine self = this; + Preconditions.checkState(!executableArgs.isEmpty()); return new CommandLine() { @Override public Iterable arguments() { - return Iterables.concat(commandLine.arguments(), args); + return Iterables.concat(executableArgs, self.arguments()); } @Override public Iterable arguments(ArtifactExpander artifactExpander) { - return Iterables.concat(commandLine.arguments(artifactExpander), args); + return Iterables.concat(executableArgs, self.arguments(artifactExpander)); } }; } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/ParamFileHelper.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/ParamFileHelper.java index d1253c98e0..e39401ac04 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/actions/ParamFileHelper.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/ParamFileHelper.java @@ -137,7 +137,7 @@ public final class ParamFileHelper { return commandLine; } - return CommandLine.concat(ImmutableList.copyOf(executableArgs), commandLine); + return commandLine.prepend(ImmutableList.copyOf(executableArgs)); } /** -- cgit v1.2.3