Skip to content

Commit

Permalink
Use TreeMap with CASE_INSENSITIVE_ORDER
Browse files Browse the repository at this point in the history
  • Loading branch information
SrBedrock committed Sep 12, 2024
1 parent f3674a8 commit 5ecd176
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ public JsonObject serializeMap(Map<String, Collection<VoteWithRecordedTimestamp>
} else {
array.add(vote.serialize());
}

}

// if, during our iteration, we TTL invalidated all the votes
if (entry.getValue().isEmpty())
if (entry.getValue().isEmpty()) {
entryItr.remove();
o.add(entry.getKey(), array);
} else {
o.add(entry.getKey(), array);
}
}
return o;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

Expand All @@ -29,7 +30,7 @@ public class MemoryVoteCache implements VoteCache {

public MemoryVoteCache(VotifierPlugin p, long voteTTL) {
voteCache = new HashMap<>();
playerVoteCache = new HashMap<>();
playerVoteCache = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

this.voteTTL = voteTTL;

Expand Down

0 comments on commit 5ecd176

Please sign in to comment.