Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1747)

Unified Diff: Source/wtf/HashFunctions.h

Issue 252633005: Enable WTF::HashSet<OwnPtr<> > (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Met comments from Erik Corry Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/xml/XPathParser.cpp ('k') | Source/wtf/HashSet.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/HashFunctions.h
diff --git a/Source/wtf/HashFunctions.h b/Source/wtf/HashFunctions.h
index f58f8e6699ff21132044cc489834e399cf035007..2b1be33e1cbc2a1437193eb25e882d929dac5988 100644
--- a/Source/wtf/HashFunctions.h
+++ b/Source/wtf/HashFunctions.h
@@ -21,6 +21,7 @@
#ifndef WTF_HashFunctions_h
#define WTF_HashFunctions_h
+#include "wtf/OwnPtr.h"
#include "wtf/RefPtr.h"
#include "wtf/StdLibExtras.h"
#include <stdint.h>
@@ -138,10 +139,12 @@ namespace WTF {
template<typename P> struct PtrHash<RefPtr<P> > : PtrHash<P*> {
using PtrHash<P*>::hash;
static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); }
+ static unsigned hash(const PassRefPtr<P>& key) { return hash(key.get()); }
using PtrHash<P*>::equal;
static bool equal(const RefPtr<P>& a, const RefPtr<P>& b) { return a == b; }
static bool equal(P* a, const RefPtr<P>& b) { return a == b; }
static bool equal(const RefPtr<P>& a, P* b) { return a == b; }
+ static bool equal(const RefPtr<P>& a, const PassRefPtr<P>& b) { return a == b; }
};
template<typename P> struct PtrHash<RawPtr<P> > : PtrHash<P*> {
using PtrHash<P*>::hash;
@@ -151,6 +154,21 @@ namespace WTF {
static bool equal(P* a, const RawPtr<P>& b) { return a == b; }
static bool equal(const RawPtr<P>& a, P* b) { return a == b; }
};
+ template<typename P> struct PtrHash<OwnPtr<P> > : PtrHash<P*> {
+ using PtrHash<P*>::hash;
+ static unsigned hash(const OwnPtr<P>& key) { return hash(key.get()); }
+ static unsigned hash(const PassOwnPtr<P>& key) { return hash(key.get()); }
+
+ static bool equal(const OwnPtr<P>& a, const OwnPtr<P>& b)
+ {
+ return a.get() == b.get();
+ }
+ static bool equal(const OwnPtr<P>& a, P* b) { return a == b; }
+ static bool equal(const OwnPtr<P>& a, const PassOwnPtr<P>& b)
+ {
+ return a.get() == b.get();
+ }
+ };
// default hash function for each type
@@ -198,6 +216,7 @@ namespace WTF {
template<typename P> struct DefaultHash<P*> { typedef PtrHash<P*> Hash; };
template<typename P> struct DefaultHash<RefPtr<P> > { typedef PtrHash<RefPtr<P> > Hash; };
template<typename P> struct DefaultHash<RawPtr<P> > { typedef PtrHash<RawPtr<P> > Hash; };
+ template<typename P> struct DefaultHash<OwnPtr<P> > { typedef PtrHash<OwnPtr<P> > Hash; };
// make IntPairHash the default hash function for pairs of (at most) 32-bit integers.
« no previous file with comments | « Source/core/xml/XPathParser.cpp ('k') | Source/wtf/HashSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698