Moved entrySet() call outside of for loop

This commit is contained in:
Luis C.M committed 2023-05-30 23:43:10 -05:00
1 parent 46febe5c0a
commit 3bc02a708e
1 file changed
+2 -1
@@ -13,7 +13,8 @@ public class CacheHashMap<K, V extends CacheHashMap.CachedObject<?>> extends Has
public V get(Object key) {
synchronized (this) {
List<K> keysToRemove = new ArrayList<>();
for (Map.Entry<K,V> entry : this.entrySet()) {
Set<Map.Entry<K,V>> entrySet = this.entrySet();
for (Map.Entry<K,V> entry : entrySet) {
if (!Objects.equals(key,entry.getKey())) {
long timeDiff = entry.getValue().timeSinceAccessed();
if (timeDiff > this.maxCacheTime) {