In `RuleConfiguredTarget`, instead of storing an `ImmutableMap<Label, Artifact>` for outputs, find output artifacts using a linear search.

The only time we need to find an output `Artifact` by its `Label` is when creating an `OutputFileConfiguredTarget`. In such case, it is sufficient to just iterate over outputs to find one with a matching label. This is fast enough because most rules have a small number of actions, and most actions only have one output. In fact, `RuleConfiguredTarget#findArtifactByOutputLabel` does not even show up in a cpu profile even after being converted from a map lookup to a linear search.

The goal of this change was to cut the memory cost of the `ImmutableMap<Label, Artifact>`, but it also extends to a nice cleanup for setting generating action keys in `Actions.java`: a lot of the complexity was due to building the `ImmutableMap<Label, Artifact>`.

The `GeneratingActions` return type used to wrap the map with the list of actions is not needed - the list of actions is already passed in as a parameter and despite the method name, there was never any filtering done. Updated method names for better clarity.

PiperOrigin-RevId: 536488854
Change-Id: I6a06315cc0cb4a1c2d9b4449c386d63e949bdb7c
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionTemplateExpansionValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionTemplateExpansionValue.java
index 402dc95..38c9ffa 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionTemplateExpansionValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionTemplateExpansionValue.java
@@ -15,10 +15,11 @@
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Interner;
+import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
 import com.google.devtools.build.lib.actions.ActionLookupKey;
 import com.google.devtools.build.lib.actions.ActionLookupKeyOrProxy;
-import com.google.devtools.build.lib.actions.Actions.GeneratingActions;
 import com.google.devtools.build.lib.actions.BasicActionLookupValue;
 import com.google.devtools.build.lib.cmdline.Label;
 import com.google.devtools.build.lib.concurrent.BlazeInterners;
@@ -27,7 +28,8 @@
 
 /** Value that stores expanded actions from ActionTemplate. */
 public final class ActionTemplateExpansionValue extends BasicActionLookupValue {
-  ActionTemplateExpansionValue(GeneratingActions generatingActions) {
+
+  ActionTemplateExpansionValue(ImmutableList<ActionAnalysisMetadata> generatingActions) {
     super(generatingActions);
   }