Skip to content

Commit

Permalink
swap to the guava's Interners.weakInterner()
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiyou06 committed Feb 22, 2025
1 parent dc2f706 commit ab0e8da
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
Expand Down

0 comments on commit ab0e8da

Please sign in to comment.