From 9fde237d9b82a16e9378ed93bc38dd78da51cb95 Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 3 Oct 2016 19:53:43 +0100 Subject: [PATCH] Swap slow get method --- .../java/me/lucko/luckperms/users/UserManager.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/users/UserManager.java b/common/src/main/java/me/lucko/luckperms/users/UserManager.java index f276b8bc8..74194f44d 100644 --- a/common/src/main/java/me/lucko/luckperms/users/UserManager.java +++ b/common/src/main/java/me/lucko/luckperms/users/UserManager.java @@ -30,7 +30,6 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.utils.AbstractManager; import me.lucko.luckperms.utils.Identifiable; -import java.util.NoSuchElementException; import java.util.UUID; @RequiredArgsConstructor @@ -44,13 +43,12 @@ public abstract class UserManager extends AbstractManager */ @SuppressWarnings("OptionalGetWithoutIsPresent") public User get(String name) { - try { - return getAll().values().stream() - .filter(u -> u.getName().equalsIgnoreCase(name)) - .limit(1).findAny().get(); - } catch (NoSuchElementException e) { - return null; + for (User user : getAll().values()) { + if (user.getName().equalsIgnoreCase(name)) { + return user; + } } + return null; } public User get(UUID uuid) {