]> granicus.if.org Git - icu/commitdiff
ICU-21569 Remove extra LocalUResourceBundlePointer
authorFrank Tang <ftang@chromium.org>
Tue, 11 May 2021 19:18:51 +0000 (12:18 -0700)
committerFrank Yung-Fong Tang <ftang@google.com>
Wed, 12 May 2021 03:46:53 +0000 (20:46 -0700)
Remove LocalUResourceBundlePointer fDictRes which shadowed the real
UUResourceBundle*.

ICU-21569 fix assert

icu4c/source/common/lstmbe.cpp

index b1f0cdd10aa6252e4e8ac1918a5265405bdba461..3da2289a1a3bbaf8376a879227455853ee8a3e45 100644 (file)
@@ -408,18 +408,19 @@ LSTMData::LSTMData(UResourceBundle* rb, UErrorCode &status)
     int32_t data_len = 0;
     const int32_t* data = ures_getIntVector(fDataRes, &data_len, &status);
     if (U_FAILURE(status)) return;
-    LocalUResourceBundlePointer fDictRes(
-        ures_getByKey(rb, "dict", nullptr, &status));
-    int32_t num_index = ures_getSize(fDictRes.getAlias());
+    fDictRes = ures_getByKey(rb, "dict", nullptr, &status);
+    if (U_FAILURE(status)) return;
+    U_ASSERT(fDictRes != nullptr);
+    int32_t num_index = ures_getSize(fDictRes);
     fDict = uhash_open(uhash_hashUChars, uhash_compareUChars, nullptr, &status);
     if (U_FAILURE(status)) return;
 
-    ures_resetIterator(fDictRes.getAlias());
+    ures_resetIterator(fDictRes);
     int32_t idx = 0;
     // put dict into hash
-    while(ures_hasNext(fDictRes.getAlias())) {
+    while(ures_hasNext(fDictRes)) {
         const char *tempKey = nullptr;
-        const UChar* str = ures_getNextString(fDictRes.getAlias(), nullptr, &tempKey, &status);
+        const UChar* str = ures_getNextString(fDictRes, nullptr, &tempKey, &status);
         if (U_FAILURE(status)) return;
         uhash_putiAllowZero(fDict, (void*)str, idx++, &status);
         if (U_FAILURE(status)) return;