mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-22696 Avoid unnecessary copies of already NUL terminated strings.
This commit is contained in:
parent
72206495de
commit
bae2aa65d8
1 changed files with 4 additions and 1 deletions
|
@ -21,7 +21,10 @@ U_NAMESPACE_USE
|
|||
ULocale*
|
||||
ulocale_openForLocaleID(const char* localeID, int32_t length, UErrorCode* err) {
|
||||
if (U_FAILURE(*err)) { return nullptr; }
|
||||
CharString str(length < 0 ? StringPiece(localeID) : StringPiece(localeID, length), *err);
|
||||
if (length < 0) {
|
||||
return EXTERNAL(icu::Locale::createFromName(localeID).clone());
|
||||
}
|
||||
CharString str(localeID, length, *err); // Make a NUL terminated copy.
|
||||
if (U_FAILURE(*err)) { return nullptr; }
|
||||
return EXTERNAL(icu::Locale::createFromName(str.data()).clone());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue