mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +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
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