Chromium Code Reviews| Index: Source/wtf/HashFunctions.h |
| diff --git a/Source/wtf/HashFunctions.h b/Source/wtf/HashFunctions.h |
| index f58f8e6699ff21132044cc489834e399cf035007..908678ddec444daa4eff5d6e7d79dd2d73ee5336 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,23 @@ 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) |
| + { |
| + RELEASE_ASSERT(!a || a.get() != b.get()); |
|
Erik Corry
2014/04/28 07:53:03
I understand why you have this, but I think RELEAS
Mikhail
2014/04/28 08:00:40
Oh, thanks for the catch! I've put it for debuggin
|
| + 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) |
| + { |
| + RELEASE_ASSERT(!a || a.get() != b.get()); |
| + return a.get() == b.get(); |
| + } |
| + }; |
| // default hash function for each type |
| @@ -198,6 +218,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. |