mirror of
https://github.com/RGBCube/serenity
synced 2025-07-31 15:37:47 +00:00
Everywhere: Rename equals_ignoring_case => equals_ignoring_ascii_case
Let's make it clear that these functions deal with ASCII case only.
This commit is contained in:
parent
03cc45e5a2
commit
a504ac3e2a
76 changed files with 480 additions and 476 deletions
|
@ -107,9 +107,9 @@ Optional<float> DeprecatedFlyString::to_float(TrimWhitespace trim_whitespace) co
|
|||
}
|
||||
#endif
|
||||
|
||||
bool DeprecatedFlyString::equals_ignoring_case(StringView other) const
|
||||
bool DeprecatedFlyString::equals_ignoring_ascii_case(StringView other) const
|
||||
{
|
||||
return StringUtils::equals_ignoring_case(view(), other);
|
||||
return StringUtils::equals_ignoring_ascii_case(view(), other);
|
||||
}
|
||||
|
||||
bool DeprecatedFlyString::starts_with(StringView str, CaseSensitivity case_sensitivity) const
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
Optional<float> to_float(TrimWhitespace = TrimWhitespace::Yes) const;
|
||||
#endif
|
||||
|
||||
bool equals_ignoring_case(StringView) const;
|
||||
bool equals_ignoring_ascii_case(StringView) const;
|
||||
bool starts_with(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
bool ends_with(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
|
||||
|
|
|
@ -346,9 +346,9 @@ bool DeprecatedString::contains(char needle, CaseSensitivity case_sensitivity) c
|
|||
return StringUtils::contains(*this, StringView(&needle, 1), case_sensitivity);
|
||||
}
|
||||
|
||||
bool DeprecatedString::equals_ignoring_case(StringView other) const
|
||||
bool DeprecatedString::equals_ignoring_ascii_case(StringView other) const
|
||||
{
|
||||
return StringUtils::equals_ignoring_case(view(), other);
|
||||
return StringUtils::equals_ignoring_ascii_case(view(), other);
|
||||
}
|
||||
|
||||
DeprecatedString DeprecatedString::reverse() const
|
||||
|
|
|
@ -148,7 +148,7 @@ public:
|
|||
return trimmed_view;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool equals_ignoring_case(StringView) const;
|
||||
[[nodiscard]] bool equals_ignoring_ascii_case(StringView) const;
|
||||
|
||||
[[nodiscard]] bool contains(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
[[nodiscard]] bool contains(char, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
|
@ -310,14 +310,14 @@ public:
|
|||
}
|
||||
|
||||
template<typename... Ts>
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of_ignoring_case(Ts&&... strings) const
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of_ignoring_ascii_case(Ts&&... strings) const
|
||||
{
|
||||
return (... ||
|
||||
[this, &strings]() -> bool {
|
||||
if constexpr (requires(Ts a) { a.view()->StringView; })
|
||||
return this->equals_ignoring_case(forward<Ts>(strings.view()));
|
||||
return this->equals_ignoring_ascii_case(forward<Ts>(strings.view()));
|
||||
else
|
||||
return this->equals_ignoring_case(forward<Ts>(strings));
|
||||
return this->equals_ignoring_ascii_case(forward<Ts>(strings));
|
||||
}());
|
||||
}
|
||||
|
||||
|
@ -330,9 +330,10 @@ struct Traits<DeprecatedString> : public GenericTraits<DeprecatedString> {
|
|||
static unsigned hash(DeprecatedString const& s) { return s.impl() ? s.impl()->hash() : 0; }
|
||||
};
|
||||
|
||||
// FIXME: Rename this to indicate that it's about ASCII-only case insensitivity.
|
||||
struct CaseInsensitiveStringTraits : public Traits<DeprecatedString> {
|
||||
static unsigned hash(DeprecatedString const& s) { return s.impl() ? s.impl()->case_insensitive_hash() : 0; }
|
||||
static bool equals(DeprecatedString const& a, DeprecatedString const& b) { return a.equals_ignoring_case(b); }
|
||||
static bool equals(DeprecatedString const& a, DeprecatedString const& b) { return a.equals_ignoring_ascii_case(b); }
|
||||
};
|
||||
|
||||
DeprecatedString escape_html_entities(StringView html);
|
||||
|
|
|
@ -182,8 +182,7 @@ bool FlyString::equals_ignoring_ascii_case(FlyString const& other) const
|
|||
{
|
||||
if (*this == other)
|
||||
return true;
|
||||
// FIXME: Rename StringUtils::equals_ignoring_case to equals_ignoring_ascii_case.
|
||||
return StringUtils::equals_ignoring_case(bytes_as_string_view(), other.bytes_as_string_view());
|
||||
return StringUtils::equals_ignoring_ascii_case(bytes_as_string_view(), other.bytes_as_string_view());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ template Optional<double> convert_to_floating_point(StringView str, TrimWhitespa
|
|||
template Optional<float> convert_to_floating_point(StringView str, TrimWhitespace);
|
||||
#endif
|
||||
|
||||
bool equals_ignoring_case(StringView a, StringView b)
|
||||
bool equals_ignoring_ascii_case(StringView a, StringView b)
|
||||
{
|
||||
if (a.length() != b.length())
|
||||
return false;
|
||||
|
|
|
@ -79,7 +79,7 @@ Optional<T> convert_to_uint_from_octal(StringView, TrimWhitespace = TrimWhitespa
|
|||
template<typename T>
|
||||
Optional<T> convert_to_floating_point(StringView, TrimWhitespace = TrimWhitespace::Yes);
|
||||
#endif
|
||||
bool equals_ignoring_case(StringView, StringView);
|
||||
bool equals_ignoring_ascii_case(StringView, StringView);
|
||||
bool ends_with(StringView a, StringView b, CaseSensitivity);
|
||||
bool starts_with(StringView, StringView, CaseSensitivity);
|
||||
bool contains(StringView, StringView, CaseSensitivity);
|
||||
|
|
|
@ -170,9 +170,9 @@ bool StringView::contains(StringView needle, CaseSensitivity case_sensitivity) c
|
|||
return StringUtils::contains(*this, needle, case_sensitivity);
|
||||
}
|
||||
|
||||
bool StringView::equals_ignoring_case(StringView other) const
|
||||
bool StringView::equals_ignoring_ascii_case(StringView other) const
|
||||
{
|
||||
return StringUtils::equals_ignoring_case(*this, other);
|
||||
return StringUtils::equals_ignoring_ascii_case(*this, other);
|
||||
}
|
||||
|
||||
#ifndef KERNEL
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
[[nodiscard]] bool contains(char) const;
|
||||
[[nodiscard]] bool contains(u32) const;
|
||||
[[nodiscard]] bool contains(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
[[nodiscard]] bool equals_ignoring_case(StringView other) const;
|
||||
[[nodiscard]] bool equals_ignoring_ascii_case(StringView) const;
|
||||
|
||||
[[nodiscard]] StringView trim(StringView characters, TrimMode mode = TrimMode::Both) const { return StringUtils::trim(*this, characters, mode); }
|
||||
[[nodiscard]] StringView trim_whitespace(TrimMode mode = TrimMode::Both) const { return StringUtils::trim_whitespace(*this, mode); }
|
||||
|
@ -337,14 +337,14 @@ public:
|
|||
}
|
||||
|
||||
template<typename... Ts>
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of_ignoring_case(Ts&&... strings) const
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of_ignoring_ascii_case(Ts&&... strings) const
|
||||
{
|
||||
return (... ||
|
||||
[this, &strings]() -> bool {
|
||||
if constexpr (requires(Ts a) { a.view()->StringView; })
|
||||
return this->equals_ignoring_case(forward<Ts>(strings.view()));
|
||||
return this->equals_ignoring_ascii_case(forward<Ts>(strings.view()));
|
||||
else
|
||||
return this->equals_ignoring_case(forward<Ts>(strings));
|
||||
return this->equals_ignoring_ascii_case(forward<Ts>(strings));
|
||||
}());
|
||||
}
|
||||
|
||||
|
@ -359,6 +359,7 @@ struct Traits<StringView> : public GenericTraits<StringView> {
|
|||
static unsigned hash(StringView s) { return s.hash(); }
|
||||
};
|
||||
|
||||
// FIXME: Rename this to indicate that it's about ASCII-only case insensitivity.
|
||||
struct CaseInsensitiveStringViewTraits : public Traits<StringView> {
|
||||
static unsigned hash(StringView s)
|
||||
{
|
||||
|
@ -366,7 +367,7 @@ struct CaseInsensitiveStringViewTraits : public Traits<StringView> {
|
|||
return 0;
|
||||
return case_insensitive_string_hash(s.characters_without_null_termination(), s.length());
|
||||
}
|
||||
static bool equals(StringView const& a, StringView const& b) { return a.equals_ignoring_case(b); }
|
||||
static bool equals(StringView const& a, StringView const& b) { return a.equals_ignoring_ascii_case(b); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -108,12 +108,12 @@ constexpr bool is_normalized_windows_drive_letter(StringView input)
|
|||
|
||||
constexpr bool is_single_dot_path_segment(StringView input)
|
||||
{
|
||||
return input == "."sv || input.equals_ignoring_case("%2e"sv);
|
||||
return input == "."sv || input.equals_ignoring_ascii_case("%2e"sv);
|
||||
}
|
||||
|
||||
constexpr bool is_double_dot_path_segment(StringView input)
|
||||
{
|
||||
return input == ".."sv || input.equals_ignoring_case(".%2e"sv) || input.equals_ignoring_case("%2e."sv) || input.equals_ignoring_case("%2e%2e"sv);
|
||||
return input == ".."sv || input.equals_ignoring_ascii_case(".%2e"sv) || input.equals_ignoring_ascii_case("%2e."sv) || input.equals_ignoring_ascii_case("%2e%2e"sv);
|
||||
}
|
||||
|
||||
// https://url.spec.whatwg.org/#string-percent-encode-after-encoding
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue