9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-25 09:59:15 +00:00

swap to the guava's Interners.weakInterner()

This commit is contained in:
Taiyou06
2025-02-22 19:55:50 +01:00
parent dc2f706b67
commit ab0e8da1dc

View File

@@ -1,23 +1,19 @@
package org.dreeam.leaf.util.map;
import com.github.benmanes.caffeine.cache.Interner;
import com.google.common.collect.Interners;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import java.util.Map;
import java.util.function.Function;
/**
* Backed by an {@link Object2ObjectOpenHashMap}, with string keys interned to save memory.
*/
public class StringCanonizingOpenHashMap<T> extends Object2ObjectOpenHashMap<String, T> {
private static final Interner<String> KEY_INTERNER = Interner.newWeakInterner();
private static final com.google.common.collect.Interner<String> KEY_INTERNER = Interners.newWeakInterner();
private static String intern(String key) {
return key != null ? KEY_INTERNER.intern(key) : null;
}
public StringCanonizingOpenHashMap() {
super();
}