AK: Simplify and optimize ASCIICaseInsensitiveFlyStringTraits::equals

The member function `equals_ignoring_ascii_case` has a fast path which
will return early if it is the same FlyString instance.
This commit is contained in:
Shannon Booth 2024-04-06 12:24:04 +02:00 committed by Tim Flynn
parent f186e7e537
commit 8c34842962
Notes: sideshowbarker 2024-07-17 01:46:00 +09:00

View file

@ -97,7 +97,7 @@ struct Formatter<FlyString> : Formatter<StringView> {
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()); }
static bool equals(FlyString const& a, FlyString const& b) { return a.equals_ignoring_ascii_case(b); }
};
}