Skip to content

Commit 3ffacba

Browse files
gvictormarkusicu
authored andcommitted
ICU-23371 Intern subdivision strings with a local pool instead of String.intern()
A local temporary pool is faster than String.intern() and the memory used by the table could be released by the GC.
1 parent d5fd603 commit 3ffacba

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

icu4j/main/core/src/main/java/com/ibm/icu/impl/ValidIdentifiers.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static class ValiditySet {
5353

5454
public ValiditySet(Set<String> plainData, boolean makeMap) {
5555
if (makeMap) {
56+
Map<String, String> uniqueSubdivisions = new HashMap<String, String>();
5657
HashMap<String, Set<String>> _subdivisionData = new HashMap<String, Set<String>>();
5758
for (String s : plainData) {
5859
int pos = s.indexOf('-'); // read v28 data also
@@ -61,7 +62,8 @@ public ValiditySet(Set<String> plainData, boolean makeMap) {
6162
pos2 = pos = s.charAt(0) < 'A' ? 3 : 2;
6263
}
6364
final String key = s.substring(0, pos);
64-
final String subdivision = s.substring(pos2).intern();
65+
String subdivision =
66+
uniqueSubdivisions.computeIfAbsent(s.substring(pos2), k -> k);
6567

6668
Set<String> oldSet = _subdivisionData.get(key);
6769
if (oldSet == null) {

0 commit comments

Comments
 (0)