(minor) Clean up StringPool

This commit is contained in:
Viktor Lofgren 2023-06-12 17:42:28 +02:00 committed by Viktor
parent e4372289a5
commit d1a004bea6

View File

@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Objects;
public class StringPool { public class StringPool {
@ -29,10 +30,7 @@ public class StringPool {
final String ret = words.putIfAbsent(str, str); final String ret = words.putIfAbsent(str, str);
ages.put(ret, idx++); ages.put(ret, idx++);
if (null == ret) return Objects.requireNonNullElse(ret, str);
return str;
return ret;
} }
public String[] internalize(String[] str) { public String[] internalize(String[] str) {