From c8d09820dc027f6c5a2e3061050446309601910a Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Tue, 24 Dec 2019 08:27:41 -0500 Subject: [PATCH] [O] General optimizations --- src/main/java/cc/moecraft/icq/user/GroupManager.java | 7 +++---- src/main/java/cc/moecraft/icq/user/UserManager.java | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/cc/moecraft/icq/user/GroupManager.java b/src/main/java/cc/moecraft/icq/user/GroupManager.java index e696967d..3ca6d717 100644 --- a/src/main/java/cc/moecraft/icq/user/GroupManager.java +++ b/src/main/java/cc/moecraft/icq/user/GroupManager.java @@ -29,11 +29,10 @@ public class GroupManager */ public Group getGroupFromID(long id) { - if (groupCache.containsKey(id)) + if (!groupCache.containsKey(id)) { - return groupCache.get(id); + groupCache.put(id, new Group(bot, id)); } - groupCache.put(id, new Group(bot, id)); - return getGroupFromID(id); + return groupCache.get(id); } } diff --git a/src/main/java/cc/moecraft/icq/user/UserManager.java b/src/main/java/cc/moecraft/icq/user/UserManager.java index 98afe264..1f3f055e 100644 --- a/src/main/java/cc/moecraft/icq/user/UserManager.java +++ b/src/main/java/cc/moecraft/icq/user/UserManager.java @@ -29,11 +29,10 @@ public class UserManager */ public User getUserFromID(long id) { - if (userCache.containsKey(id)) + if (!userCache.containsKey(id)) { - return userCache.get(id); + userCache.put(id, new User(bot, id)); } - userCache.put(id, new User(bot, id)); - return getUserFromID(id); + return userCache.get(id); } }