mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add comparison operator
s p a c e s h i p o p e r a t o r Comparing UTF-8 can be done by simple byte lexicographic comparison per definition, so we just piggy-back on StringView's high-performance comparator.
This commit is contained in:
parent
ad6a55e1f0
commit
ca80353efe
Notes:
sideshowbarker
2024-07-17 08:35:21 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/ca80353efe Pull-request: https://github.com/SerenityOS/serenity/pull/14393 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/sin-ack
1 changed files with 3 additions and 0 deletions
|
@ -73,6 +73,9 @@ public:
|
|||
[[nodiscard]] bool operator==(char const* cstring) const;
|
||||
[[nodiscard]] bool operator!=(char const* cstring) const { return !(*this == cstring); }
|
||||
|
||||
// NOTE: UTF-8 is defined in a way that lexicographic ordering of code points is equivalent to lexicographic ordering of bytes.
|
||||
[[nodiscard]] int operator<=>(String const& other) const { return this->bytes_as_string_view().compare(other.bytes_as_string_view()); }
|
||||
|
||||
[[nodiscard]] u32 hash() const;
|
||||
|
||||
template<Arithmetic T>
|
||||
|
|
Loading…
Reference in a new issue