diff options
author | Googler <noreply@google.com> | 2018-05-28 07:33:04 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-28 07:35:44 -0700 |
commit | a9c0d4e41efa3fc684de3065e74b9a6f82ec260d (patch) | |
tree | 7faa99b4b8e7aa96b8457593094b189434210265 /src/main/java/com | |
parent | 993b8bfbf47851e54907899de6c5aa493c585f6b (diff) |
Don't create a HashSet/Map just to copy them into the Immutable-counterpart
later. This wastes CPU cycles (directly and during GC).
RELNOTES: None.
PiperOrigin-RevId: 198302706
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java index 7867fd2de1..503e8ce2fe 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java @@ -32,7 +32,6 @@ import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.List; /** @@ -243,8 +242,8 @@ public class HeaderDiscovery { /** Creates a CppHeaderDiscovery instance. */ public HeaderDiscovery build() { - HashMap<PathFragment, Artifact> allowedDerivedInputsMap = new HashMap<>(); - HashSet<PathFragment> treeArtifactPrefixes = new HashSet<>(); + ImmutableMap.Builder<PathFragment, Artifact> allowedDerivedInputsMap = ImmutableMap.builder(); + ImmutableSet.Builder<PathFragment> treeArtifactPrefixes = ImmutableSet.builder(); for (Artifact a : allowedDerivedInputs) { if (a.isTreeArtifact()) { treeArtifactPrefixes.add(a.getExecPath()); @@ -258,8 +257,8 @@ public class HeaderDiscovery { shouldValidateInclusions, dependencies, permittedSystemIncludePrefixes, - ImmutableMap.copyOf(allowedDerivedInputsMap), - ImmutableSet.copyOf(treeArtifactPrefixes)); + allowedDerivedInputsMap.build(), + treeArtifactPrefixes.build()); } } } |