From 26d5a40229a99c3896f43c90cfb0416a9bec5718 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 17 Jan 2019 03:28:07 -0800 Subject: [PATCH] Don't iterate over a large map just to delete an empty list of SkyKeys. RELNOTES: None. PiperOrigin-RevId: 229715756 --- .../build/lib/skyframe/SequencedSkyframeExecutor.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java index a8264d5626a375..cda7742938e4b4 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java @@ -353,6 +353,10 @@ private void invalidateDeletedPackages(Iterable deletedPackag for (PackageIdentifier deletedPackage : deletedPackages) { packagesToInvalidate.add(PackageLookupValue.key(deletedPackage)); } + // Exit early if there are no packages to be deleted to avoid iterating over a large map. + if (packagesToInvalidate.isEmpty()) { + return; + } memoizingEvaluator.delete(Predicates.in(packagesToInvalidate)); }