mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 05:27:14 +09:00
LibUnicode: Provide string length to ICU string enumeration callbacks
Some callers need the raw nul-terminated c-string in this callback, to pass to some other ICU method. But other callers will want a StringView. We know the length already in `icu_string_enumeration_to_list`, so let's just pass it along to avoid `strlen`.
This commit is contained in:
parent
21cff645a2
commit
422d72e85d
Notes:
github-actions[bot]
2025-06-02 21:04:57 +00:00
Author: https://github.com/trflynn89
Commit: 422d72e85d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4970
3 changed files with 5 additions and 5 deletions
|
@ -118,7 +118,7 @@ Vector<String> icu_string_enumeration_to_list(OwnPtr<icu::StringEnumeration> enu
|
|||
if (icu_failure(status) || value == nullptr)
|
||||
break;
|
||||
|
||||
if (!filter(value))
|
||||
if (!filter(value, static_cast<size_t>(length)))
|
||||
continue;
|
||||
|
||||
if (bcp47_keyword) {
|
||||
|
@ -134,7 +134,7 @@ Vector<String> icu_string_enumeration_to_list(OwnPtr<icu::StringEnumeration> enu
|
|||
|
||||
ALWAYS_INLINE Vector<String> icu_string_enumeration_to_list(OwnPtr<icu::StringEnumeration> enumeration, char const* bcp47_keyword)
|
||||
{
|
||||
return icu_string_enumeration_to_list(move(enumeration), bcp47_keyword, [](char const*) { return true; });
|
||||
return icu_string_enumeration_to_list(move(enumeration), bcp47_keyword, [](char const*, size_t) { return true; });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -107,8 +107,8 @@ static Vector<String> icu_available_time_zones(Optional<ByteString> const& regio
|
|||
if (icu_failure(status))
|
||||
return { "UTC"_string };
|
||||
|
||||
auto time_zones = icu_string_enumeration_to_list(move(time_zone_enumerator), nullptr, [](char const* zone) {
|
||||
return !is_legacy_non_iana_time_zone({ zone, strlen(zone) });
|
||||
auto time_zones = icu_string_enumeration_to_list(move(time_zone_enumerator), nullptr, [](char const* zone, size_t zone_length) {
|
||||
return !is_legacy_non_iana_time_zone({ zone, zone_length });
|
||||
});
|
||||
|
||||
quick_sort(time_zones);
|
||||
|
|
|
@ -153,7 +153,7 @@ Vector<String> const& available_number_systems()
|
|||
if (icu_failure(status))
|
||||
return {};
|
||||
|
||||
auto number_systems = icu_string_enumeration_to_list(move(keywords), "nu", [&](char const* keyword) {
|
||||
auto number_systems = icu_string_enumeration_to_list(move(keywords), "nu", [&](char const* keyword, size_t) {
|
||||
auto system = adopt_own_if_nonnull(icu::NumberingSystem::createInstanceByName(keyword, status));
|
||||
if (icu_failure(status))
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue