1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:37:34 +00:00

LibWeb: Implement CaseInsensitiveBytesTraits::equals()

Turns out HashTable::contains() doesn't solely use hash() for equality
checks, so the lack of a proper equals() implementation broke the check
in convert_header_names_to_a_sorted_lowercase_set() and caused duplicate
entries in header_names_set.
This commit is contained in:
Linus Groh 2022-07-19 00:18:45 +01:00
parent 6b64ca4bb8
commit bad6ad8861

View file

@ -20,7 +20,12 @@ namespace Web::Fetch::Infrastructure {
template<typename T>
requires(IsSameIgnoringCV<T, u8>) struct CaseInsensitiveBytesTraits : public Traits<Span<T>> {
static unsigned hash(Span<T> const& span)
static constexpr bool equals(Span<T> const& a, Span<T> const& b)
{
return StringView { a }.equals_ignoring_case(StringView { b });
}
static constexpr unsigned hash(Span<T> const& span)
{
if (span.is_empty())
return 0;