mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19: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
|
@ -36,6 +36,7 @@ public:
|
|||
|
||||
[[nodiscard]] bool is_empty() const;
|
||||
[[nodiscard]] unsigned hash() const;
|
||||
[[nodiscard]] u32 ascii_case_insensitive_hash() const;
|
||||
|
||||
explicit operator String() const;
|
||||
String to_string() const;
|
||||
|
@ -88,6 +89,11 @@ struct Formatter<FlyString> : Formatter<StringView> {
|
|||
ErrorOr<void> format(FormatBuilder&, FlyString const&);
|
||||
};
|
||||
|
||||
struct ASCIICaseInsensitiveFlyStringTraits : public Traits<String> {
|
||||
static unsigned hash(FlyString const& s) { return s.ascii_case_insensitive_hash(); }
|
||||
static bool equals(FlyString const& a, FlyString const& b) { return a.bytes().data() == b.bytes().data() || a.bytes_as_string_view().equals_ignoring_ascii_case(b.bytes_as_string_view()); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE AK::FlyString operator""_fly_string(char const* cstring, size_t length)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue