ICU-7434 switch BreakIterator.iterCache from SoftReference to CacheValue

X-SVN-Rev: 38737
This commit is contained in:
Markus Scherer 2016-05-13 21:23:20 +00:00
parent c1633486ae
commit fa28f03bf6

View file

@ -7,13 +7,13 @@
package com.ibm.icu.text;
import java.lang.ref.SoftReference;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.Locale;
import java.util.MissingResourceException;
import com.ibm.icu.impl.ICUDebug;
import com.ibm.icu.impl.CacheValue;
import com.ibm.icu.util.ICUCloneNotSupportedException;
import com.ibm.icu.util.ULocale;
@ -556,7 +556,7 @@ public abstract class BreakIterator implements Cloneable
*/
private static final int KIND_COUNT = 5;
private static final SoftReference<?>[] iterCache = new SoftReference<?>[5];
private static final CacheValue<?>[] iterCache = new CacheValue<?>[5];
/**
* Returns a new instance of BreakIterator that locates word boundaries.
@ -867,7 +867,7 @@ s */
BreakIterator result = getShim().createBreakIterator(where, kind);
BreakIteratorCache cache = new BreakIteratorCache(where, result);
iterCache[kind] = new SoftReference<BreakIteratorCache>(cache);
iterCache[kind] = CacheValue.getInstance(cache);
if (result instanceof RuleBasedBreakIterator) {
RuleBasedBreakIterator rbbi = (RuleBasedBreakIterator)result;
rbbi.setBreakType(kind);