From 49f51f24f7b1c27b787c05a4707cdec98b570607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Sun, 17 May 2020 18:02:26 +0200 Subject: [PATCH] Don't loop services when all mappings have been found --- .../java/com/plotsquared/core/uuid/UUIDPipeline.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java b/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java index 0df18ea94..e14df5de0 100644 --- a/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java +++ b/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java @@ -140,12 +140,18 @@ public class UUIDPipeline { */ public CompletableFuture> getNames( @NotNull final Collection requests) { + if (requests.isEmpty()) { + return CompletableFuture.completedFuture(Collections.emptyList()); + } final List serviceList = this.getServiceListInstance(); return CompletableFuture.supplyAsync(() -> { final List mappings = new ArrayList<>(requests.size()); final List remainingRequests = new ArrayList<>(requests); for (final UUIDService service : serviceList) { + if (remainingRequests.isEmpty()) { + break; + } final List completedRequests = service.getNames(remainingRequests); for (final UUIDMapping mapping : completedRequests) { remainingRequests.remove(mapping.getUuid()); @@ -170,12 +176,18 @@ public class UUIDPipeline { */ public CompletableFuture> getUUIDs( @NotNull final Collection requests) { + if (requests.isEmpty()) { + return CompletableFuture.completedFuture(Collections.emptyList()); + } final List serviceList = this.getServiceListInstance(); return CompletableFuture.supplyAsync(() -> { final List mappings = new ArrayList<>(requests.size()); final List remainingRequests = new ArrayList<>(requests); for (final UUIDService service : serviceList) { + if (remainingRequests.isEmpty()) { + break; + } final List completedRequests = service.getUUIDs(remainingRequests); for (final UUIDMapping mapping : completedRequests) { remainingRequests.remove(mapping.getUsername());