AK: Implement StringView::to_{lower,upper}case_string

This patch refactors StringImpl::to_{lower,upper}case to use the new
static methods StringImpl::create_{lower,upper}cased if they have to use
to create a new StringImpl. This allows implementing StringView's
to_{lower,upper}case_string using the same methods.

It also replaces the usage of hand-written to_ascii_lowercase() and
similar methods with those from CharacterTypes.h.
This commit is contained in:
Max Wipfli 2021-07-01 13:45:59 +02:00 committed by Andreas Kling
parent 5ce9305c5f
commit 3ea65200d8
Notes: sideshowbarker 2024-07-18 11:06:25 +09:00
4 changed files with 41 additions and 36 deletions

View file

@ -173,6 +173,16 @@ bool StringView::equals_ignoring_case(const StringView& other) const
return StringUtils::equals_ignoring_case(*this, other);
}
String StringView::to_lowercase_string() const
{
return StringImpl::create_lowercased(characters_without_null_termination(), length());
}
String StringView::to_uppercase_string() const
{
return StringImpl::create_uppercased(characters_without_null_termination(), length());
}
StringView StringView::substring_view_starting_from_substring(const StringView& substring) const
{
const char* remaining_characters = substring.characters_without_null_termination();