]> granicus.if.org Git - icu/commitdiff
ICU-12746 avoid checking for possibly-interned String; instead store the no-inheritan...
authorMarkus Scherer <markus.icu@gmail.com>
Wed, 21 Sep 2016 20:21:09 +0000 (20:21 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Wed, 21 Sep 2016 20:21:09 +0000 (20:21 +0000)
X-SVN-Rev: 39316

icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundle.java
icu4j/main/classes/core/src/com/ibm/icu/impl/TimeZoneNamesImpl.java

index 1a06e8aa6a440456f57a96ff2868ecc3bd381371..9c6558ba752dfb0ff9e18a3b45fa0fbdd5b1fdba 100644 (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
index 3d2900fcabbe2816399280f7bad495c91d9c6454..afc57d0fa218ddd2800a143ec32946faee75ae54 100644 (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;