From 5ffb2897d7d0772094ae4dc91c938d3045e27795 Mon Sep 17 00:00:00 2001 From: Pepijn Van Eeckhoudt Date: Thu, 12 May 2022 08:22:43 +0200 Subject: [PATCH] fix: Avoid potential slow Set#removeAll call in HierarchicalCommunicationController#passivateInactiveKeys The performance of calling Set#removeAll(List) is dependent on the relative sizes of the Set and List parameter. Replace Set#removeAll with List#forEach(Set::remove) to avoid this. Fixes #13745 --- .../provider/hierarchy/HierarchicalCommunicationController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flow-data/src/main/java/com/vaadin/flow/data/provider/hierarchy/HierarchicalCommunicationController.java b/flow-data/src/main/java/com/vaadin/flow/data/provider/hierarchy/HierarchicalCommunicationController.java index 3efb9354128..cf94981d523 100644 --- a/flow-data/src/main/java/com/vaadin/flow/data/provider/hierarchy/HierarchicalCommunicationController.java +++ b/flow-data/src/main/java/com/vaadin/flow/data/provider/hierarchy/HierarchicalCommunicationController.java @@ -287,7 +287,7 @@ private void passivateInactiveKeys(Set oldActive, } // Finally clear any passivated items that have now been confirmed - oldActive.removeAll(newActiveKeyOrder); + newActiveKeyOrder.forEach(oldActive::remove); if (!oldActive.isEmpty()) { passivatedByUpdate.put(Integer.valueOf(updateId), oldActive); }