Reduce allocations if a singleton set is already mutable

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent df68f6d801
commit e384d634cc
  1. 2
      cache/src/main/kotlin/org/openrs2/cache/NamedEntryCollection.kt

@ -249,7 +249,7 @@ public abstract class NamedEntryCollection<T : NamedEntry>(
val set = nameHashTable[newNameHash]
when {
set == null -> nameHashTable[newNameHash] = IntSortedSets.singleton(id)
set.size == 1 -> {
set is IntSortedSets.Singleton -> {
val newSet = IntAVLTreeSet()
newSet.add(set.firstInt())
newSet.add(id)

Loading…
Cancel
Save