From 5d7cbdbc025160a51d96118450c7d1ea1a34e4d8 Mon Sep 17 00:00:00 2001 From: Fredrik Roubert Date: Thu, 18 Jul 2024 20:59:42 +0200 Subject: [PATCH] ICU-22696 Delete unused code. These optional output parameters weren't used when these function were originally added so they were most likely included just in case someone would want to use them in the future, but that was 10 years ago now and they still haven't been used yet, so it's unlikely that they'll be used in the foreseeable future and call sites as well as the implementation can instead be simplified by removing them. --- icu4c/source/common/locid.cpp | 2 +- icu4c/source/common/uloc.cpp | 4 ++-- icu4c/source/common/uloc_keytype.cpp | 30 ++-------------------------- icu4c/source/common/ulocimp.h | 4 ++-- 4 files changed, 7 insertions(+), 33 deletions(-) diff --git a/icu4c/source/common/locid.cpp b/icu4c/source/common/locid.cpp index c0757fc2f2d..df621194702 100644 --- a/icu4c/source/common/locid.cpp +++ b/icu4c/source/common/locid.cpp @@ -1570,7 +1570,7 @@ AliasReplacer::replaceTransformedExtensions( // Split the "tkey-tvalue" pair string so that we can canonicalize the tvalue. *const_cast(tvalue++) = '\0'; // NUL terminate tkey output.append(tfield, status).append('-', status); - const char* bcpTValue = ulocimp_toBcpType(tfield, tvalue, nullptr, nullptr); + const char* bcpTValue = ulocimp_toBcpType(tfield, tvalue); output.append((bcpTValue == nullptr) ? tvalue : bcpTValue, status); } } diff --git a/icu4c/source/common/uloc.cpp b/icu4c/source/common/uloc.cpp index 3a4d3b59541..c2b7bbfd6af 100644 --- a/icu4c/source/common/uloc.cpp +++ b/icu4c/source/common/uloc.cpp @@ -2296,7 +2296,7 @@ uloc_toUnicodeLocaleKey(const char* keyword) U_CAPI const char* U_EXPORT2 uloc_toUnicodeLocaleType(const char* keyword, const char* value) { - const char* bcpType = ulocimp_toBcpType(keyword, value, nullptr, nullptr); + const char* bcpType = ulocimp_toBcpType(keyword, value); if (bcpType == nullptr && ultag_isUnicodeLocaleType(value, -1)) { // unknown keyword, but syntax is fine.. return value; @@ -2364,7 +2364,7 @@ uloc_toLegacyKey(const char* keyword) U_CAPI const char* U_EXPORT2 uloc_toLegacyType(const char* keyword, const char* value) { - const char* legacyType = ulocimp_toLegacyType(keyword, value, nullptr, nullptr); + const char* legacyType = ulocimp_toLegacyType(keyword, value); if (legacyType == nullptr) { // Checks if the specified locale type is well-formed with the legacy locale syntax. // diff --git a/icu4c/source/common/uloc_keytype.cpp b/icu4c/source/common/uloc_keytype.cpp index e374da450b5..6ea886ca295 100644 --- a/icu4c/source/common/uloc_keytype.cpp +++ b/icu4c/source/common/uloc_keytype.cpp @@ -449,23 +449,13 @@ ulocimp_toLegacyKey(const char* key) { } U_EXPORT const char* -ulocimp_toBcpType(const char* key, const char* type, bool* isKnownKey, bool* isSpecialType) { - if (isKnownKey != nullptr) { - *isKnownKey = false; - } - if (isSpecialType != nullptr) { - *isSpecialType = false; - } - +ulocimp_toBcpType(const char* key, const char* type) { if (!init()) { return nullptr; } LocExtKeyData* keyData = static_cast(uhash_get(gLocExtKeyMap, key)); if (keyData != nullptr) { - if (isKnownKey != nullptr) { - *isKnownKey = true; - } LocExtType* t = static_cast(uhash_get(keyData->typeMap.getAlias(), type)); if (t != nullptr) { return t->bcpId; @@ -482,9 +472,6 @@ ulocimp_toBcpType(const char* key, const char* type, bool* isKnownKey, bool* isS matched = isSpecialTypeRgKeyValue(type); } if (matched) { - if (isSpecialType != nullptr) { - *isSpecialType = true; - } return type; } } @@ -494,23 +481,13 @@ ulocimp_toBcpType(const char* key, const char* type, bool* isKnownKey, bool* isS U_EXPORT const char* -ulocimp_toLegacyType(const char* key, const char* type, bool* isKnownKey, bool* isSpecialType) { - if (isKnownKey != nullptr) { - *isKnownKey = false; - } - if (isSpecialType != nullptr) { - *isSpecialType = false; - } - +ulocimp_toLegacyType(const char* key, const char* type) { if (!init()) { return nullptr; } LocExtKeyData* keyData = static_cast(uhash_get(gLocExtKeyMap, key)); if (keyData != nullptr) { - if (isKnownKey != nullptr) { - *isKnownKey = true; - } LocExtType* t = static_cast(uhash_get(keyData->typeMap.getAlias(), type)); if (t != nullptr) { return t->legacyId; @@ -527,9 +504,6 @@ ulocimp_toLegacyType(const char* key, const char* type, bool* isKnownKey, bool* matched = isSpecialTypeRgKeyValue(type); } if (matched) { - if (isSpecialType != nullptr) { - *isSpecialType = true; - } return type; } } diff --git a/icu4c/source/common/ulocimp.h b/icu4c/source/common/ulocimp.h index 7fb64062884..ff3910ac8f3 100644 --- a/icu4c/source/common/ulocimp.h +++ b/icu4c/source/common/ulocimp.h @@ -398,10 +398,10 @@ U_EXPORT const char* ulocimp_toLegacyKey(const char* key); U_EXPORT const char* -ulocimp_toBcpType(const char* key, const char* type, bool* isKnownKey, bool* isSpecialType); +ulocimp_toBcpType(const char* key, const char* type); U_EXPORT const char* -ulocimp_toLegacyType(const char* key, const char* type, bool* isKnownKey, bool* isSpecialType); +ulocimp_toLegacyType(const char* key, const char* type); /* Function for testing purpose */ U_EXPORT const char* const*