File tree Expand file tree Collapse file tree 4 files changed +22
-0
lines changed Expand file tree Collapse file tree 4 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,11 @@ unsigned FlyString::hash() const
100
100
return String::fly_string_data_to_hash ({}, m_data);
101
101
}
102
102
103
+ u32 FlyString::ascii_case_insensitive_hash () const
104
+ {
105
+ return case_insensitive_string_hash (reinterpret_cast <char const *>(bytes ().data ()), bytes ().size ());
106
+ }
107
+
103
108
FlyString::operator String () const
104
109
{
105
110
return to_string ();
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ class FlyString {
36
36
37
37
[[nodiscard]] bool is_empty () const ;
38
38
[[nodiscard]] unsigned hash () const ;
39
+ [[nodiscard]] u32 ascii_case_insensitive_hash () const ;
39
40
40
41
explicit operator String () const ;
41
42
String to_string () const ;
@@ -88,6 +89,11 @@ struct Formatter<FlyString> : Formatter<StringView> {
88
89
ErrorOr<void > format (FormatBuilder&, FlyString const &);
89
90
};
90
91
92
+ struct ASCIICaseInsensitiveFlyStringTraits : public Traits <String> {
93
+ static unsigned hash (FlyString const & s) { return s.ascii_case_insensitive_hash (); }
94
+ 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 ()); }
95
+ };
96
+
91
97
}
92
98
93
99
[[nodiscard]] ALWAYS_INLINE AK::FlyString operator " " _fly_string(char const * cstring, size_t length)
Original file line number Diff line number Diff line change @@ -439,6 +439,11 @@ u32 String::hash() const
439
439
return m_data->hash ();
440
440
}
441
441
442
+ u32 String::ascii_case_insensitive_hash () const
443
+ {
444
+ return case_insensitive_string_hash (reinterpret_cast <char const *>(bytes ().data ()), bytes ().size ());
445
+ }
446
+
442
447
Utf8View String::code_points () const
443
448
{
444
449
return Utf8View (bytes_as_string_view ());
Original file line number Diff line number Diff line change @@ -168,6 +168,7 @@ class String {
168
168
[[nodiscard]] bool contains (u32 , CaseSensitivity = CaseSensitivity::CaseSensitive) const ;
169
169
170
170
[[nodiscard]] u32 hash () const ;
171
+ [[nodiscard]] u32 ascii_case_insensitive_hash () const ;
171
172
172
173
template <Arithmetic T>
173
174
static ErrorOr<String> number (T value)
@@ -263,6 +264,11 @@ struct Formatter<String> : Formatter<StringView> {
263
264
ErrorOr<void > format (FormatBuilder&, String const &);
264
265
};
265
266
267
+ struct ASCIICaseInsensitiveStringTraits : public Traits <String> {
268
+ static unsigned hash (String const & s) { return s.ascii_case_insensitive_hash (); }
269
+ static bool equals (String const & a, String const & b) { return a.bytes_as_string_view ().equals_ignoring_ascii_case (b.bytes_as_string_view ()); }
270
+ };
271
+
266
272
}
267
273
268
274
[[nodiscard]] ALWAYS_INLINE AK::String operator " " _string(char const * cstring, size_t length)
You can’t perform that action at this time.
0 commit comments