mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-12 22:22:55 +00:00
AK: Add FlyString::equals_ignoring_case(StringView)
And share the code with String by moving the logic to StringUtils. :^)
This commit is contained in:
parent
0efa47b7ef
commit
26bc3d4ea0
Notes:
sideshowbarker
2024-07-19 08:11:05 +09:00
Author: https://github.com/awesomekling
Commit: 26bc3d4ea0
6 changed files with 31 additions and 16 deletions
|
@ -38,13 +38,6 @@
|
|||
extern "C" char* strstr(const char* haystack, const char* needle);
|
||||
#endif
|
||||
|
||||
static inline char to_lowercase(char c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
return c | 0x20;
|
||||
return c;
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
||||
bool String::operator==(const String& other) const
|
||||
|
@ -309,15 +302,7 @@ bool String::contains(const String& needle) const
|
|||
|
||||
bool String::equals_ignoring_case(const StringView& other) const
|
||||
{
|
||||
if (other.m_impl == impl())
|
||||
return true;
|
||||
if (length() != other.length())
|
||||
return false;
|
||||
for (size_t i = 0; i < length(); ++i) {
|
||||
if (::to_lowercase(characters()[i]) != ::to_lowercase(other.characters_without_null_termination()[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return StringUtils::equals_ignoring_case(view(), other);
|
||||
}
|
||||
|
||||
String escape_html_entities(const StringView& html)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue