1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

AK+LibUnicode: Implement String::equals_ignoring_case without allocating

We currently fully casefold the left- and right-hand sides to compare
two strings with case-insensitivity. Now, we casefold one code point at
a time, storing the result in a view for comparison, until we exhaust
both strings.
This commit is contained in:
Timothy Flynn 2023-03-08 13:03:04 -05:00 committed by Linus Groh
parent 4aee4e80bd
commit 1393ed2000
6 changed files with 150 additions and 52 deletions

View file

@ -29,7 +29,7 @@ ThrowCompletionOr<Optional<::Locale::LocaleID>> is_structurally_valid_language_t
quick_sort(variants);
for (size_t i = 0; i < variants.size() - 1; ++i) {
if (TRY_OR_THROW_OOM(vm, variants[i].equals_ignoring_case(variants[i + 1])))
if (variants[i].equals_ignoring_case(variants[i + 1]))
return true;
}