Selaa lähdekoodia

LibWeb: Teach AK how to hash StorageKeys

Andrew Kaster 9 kuukautta sitten
vanhempi
commit
f4f70068a8
1 muutettua tiedostoa jossa 11 lisäystä ja 0 poistoa
  1. 11 0
      Userland/Libraries/LibWeb/StorageAPI/StorageKey.h

+ 11 - 0
Userland/Libraries/LibWeb/StorageAPI/StorageKey.h

@@ -7,6 +7,7 @@
 #pragma once
 
 #include <AK/Optional.h>
+#include <AK/Traits.h>
 #include <LibURL/Origin.h>
 #include <LibWeb/Forward.h>
 
@@ -32,3 +33,13 @@ Optional<StorageKey> obtain_a_storage_key(HTML::Environment const&);
 StorageKey obtain_a_storage_key_for_non_storage_purposes(HTML::Environment const&);
 
 }
+
+namespace AK {
+template<>
+struct Traits<Web::StorageAPI::StorageKey> : public DefaultTraits<Web::StorageAPI::StorageKey> {
+    static unsigned hash(Web::StorageAPI::StorageKey const& key)
+    {
+        return Traits<URL::Origin>::hash(key.origin);
+    }
+};
+}