ICU-12746 avoid checking for possibly-interned String; instead store the no-inheritance-marker as itself, and check for that later

X-SVN-Rev: 39316
This commit is contained in:
Markus Scherer 2016-09-21 20:21:09 +00:00
parent c1425af28f
commit 588f393cec
2 changed files with 5 additions and 16 deletions

View file

@ -36,7 +36,7 @@ public class ICUResourceBundle extends UResourceBundle {
/**
* CLDR string value "∅∅∅" prevents fallback to the parent bundle.
*/
private static final String NO_INHERITANCE_MARKER = "\u2205\u2205\u2205";
public static final String NO_INHERITANCE_MARKER = "\u2205\u2205\u2205";
/**
* The class loader constant to be used with getBundleInstance API

View file

@ -582,7 +582,6 @@ public class TimeZoneNamesImpl extends TimeZoneNames {
}
private static final class ZNamesLoader extends UResource.Sink {
private static String NO_NAME = "";
private String[] names;
/**
@ -642,8 +641,7 @@ public class TimeZoneNamesImpl extends TimeZoneNames {
if (index == null) { return; }
assert index.ordinal() < ZNames.NUM_NAME_TYPES;
if (names[index.ordinal()] == null) {
String toSet = (value == null) ? NO_NAME : value.getString();
names[index.ordinal()] = toSet;
names[index.ordinal()] = value.getString();
}
}
@ -651,12 +649,8 @@ public class TimeZoneNamesImpl extends TimeZoneNames {
public void put(UResource.Key key, UResource.Value value, boolean noFallback) {
UResource.Table namesTable = value.getTable();
for (int i = 0; namesTable.getKeyAndValue(i, key, value); ++i) {
if (value.isNoInheritanceMarker()) {
setNameIfEmpty(key, null);
} else {
assert value.getType() == UResourceBundle.STRING;
setNameIfEmpty(key, value);
}
assert value.getType() == UResourceBundle.STRING;
setNameIfEmpty(key, value); // could be value.isNoInheritanceMarker()
}
}
@ -668,12 +662,7 @@ public class TimeZoneNamesImpl extends TimeZoneNames {
for (int i = 0; i < ZNames.NUM_NAME_TYPES; ++i) {
String name = names[i];
if (name != null) {
// TODO Findbugs: Comparison of String objects using == or !=
// Review the logic and modify below if necessary. See ticket #12746.
// FindBugs complains about == but
// we do want to check for the NO_NAME reference, not its contents!
if (name == NO_NAME) {
if (name.equals(ICUResourceBundle.NO_INHERITANCE_MARKER)) {
names[i] = null;
} else {
length = i + 1;