Skip to content

Commit

Permalink
ICU-22696 Delete unused code.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
roubert committed Jul 29, 2024
1 parent 06c077b commit 5d7cbdb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 33 deletions.
2 changes: 1 addition & 1 deletion icu4c/source/common/locid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ AliasReplacer::replaceTransformedExtensions(
// Split the "tkey-tvalue" pair string so that we can canonicalize the tvalue.
*const_cast<char*>(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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/common/uloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
//
Expand Down
30 changes: 2 additions & 28 deletions icu4c/source/common/uloc_keytype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LocExtKeyData*>(uhash_get(gLocExtKeyMap, key));
if (keyData != nullptr) {
if (isKnownKey != nullptr) {
*isKnownKey = true;
}
LocExtType* t = static_cast<LocExtType*>(uhash_get(keyData->typeMap.getAlias(), type));
if (t != nullptr) {
return t->bcpId;
Expand All @@ -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;
}
}
Expand All @@ -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<LocExtKeyData*>(uhash_get(gLocExtKeyMap, key));
if (keyData != nullptr) {
if (isKnownKey != nullptr) {
*isKnownKey = true;
}
LocExtType* t = static_cast<LocExtType*>(uhash_get(keyData->typeMap.getAlias(), type));
if (t != nullptr) {
return t->legacyId;
Expand All @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/common/ulocimp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down

0 comments on commit 5d7cbdb

Please sign in to comment.