mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
AK: Add case-insensitive hashing for the new String classes
Bringing over this functionality from DeprecatedString.
This commit is contained in:
parent
545d8336b8
commit
1e820385d9
Notes:
sideshowbarker
2024-07-17 18:46:30 +09:00
Author: https://github.com/awesomekling
Commit: 1e820385d9
Pull-request: https://github.com/SerenityOS/serenity/pull/20969
Reviewed-by: https://github.com/shannonbooth
Reviewed-by: https://github.com/trflynn89
4 changed files with 22 additions and 0 deletions
|
@ -168,6 +168,7 @@ public:
|
|||
[[nodiscard]] bool contains(u32, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
|
||||
|
||||
[[nodiscard]] u32 hash() const;
|
||||
[[nodiscard]] u32 ascii_case_insensitive_hash() const;
|
||||
|
||||
template<Arithmetic T>
|
||||
static ErrorOr<String> number(T value)
|
||||
|
@ -263,6 +264,11 @@ struct Formatter<String> : Formatter<StringView> {
|
|||
ErrorOr<void> format(FormatBuilder&, String const&);
|
||||
};
|
||||
|
||||
struct ASCIICaseInsensitiveStringTraits : public Traits<String> {
|
||||
static unsigned hash(String const& s) { return s.ascii_case_insensitive_hash(); }
|
||||
static bool equals(String const& a, String const& b) { return a.bytes_as_string_view().equals_ignoring_ascii_case(b.bytes_as_string_view()); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE AK::String operator""_string(char const* cstring, size_t length)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue