Title: [149602] trunk/Source/WTF
Revision
149602
Author
[email protected]
Date
2013-05-06 09:41:38 -0700 (Mon, 06 May 2013)

Log Message

Change HashTraits<RefPtr<P> >::PassOutType to PassRefPtr for better performance
https://bugs.webkit.org/show_bug.cgi?id=115410

Reviewed by Darin Adler.

The type HashTraits<RefPtr<P> >::PassOutType is PassRefPtr now to
avoid extra ref/unrefing on return from HashMap methods that transfer
ownership, such as take.

* wtf/HashTable.h:
(WTF::IdentityHashTranslator::equal):
* wtf/HashTraits.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (149601 => 149602)


--- trunk/Source/WTF/ChangeLog	2013-05-06 16:37:41 UTC (rev 149601)
+++ trunk/Source/WTF/ChangeLog	2013-05-06 16:41:38 UTC (rev 149602)
@@ -1,3 +1,18 @@
+2013-05-06  Mikhail Pozdnyakov  <[email protected]>
+
+        Change HashTraits<RefPtr<P> >::PassOutType to PassRefPtr for better performance
+        https://bugs.webkit.org/show_bug.cgi?id=115410
+
+        Reviewed by Darin Adler.
+
+        The type HashTraits<RefPtr<P> >::PassOutType is PassRefPtr now to
+        avoid extra ref/unrefing on return from HashMap methods that transfer
+        ownership, such as take.
+
+        * wtf/HashTable.h:
+        (WTF::IdentityHashTranslator::equal):
+        * wtf/HashTraits.h:
+
 2013-05-05  Anders Carlsson  <[email protected]>
 
         Remove Vector::prepend

Modified: trunk/Source/WTF/wtf/HashTable.h (149601 => 149602)


--- trunk/Source/WTF/wtf/HashTable.h	2013-05-06 16:37:41 UTC (rev 149601)
+++ trunk/Source/WTF/wtf/HashTable.h	2013-05-06 16:41:38 UTC (rev 149602)
@@ -300,7 +300,7 @@
     template<typename HashFunctions> class IdentityHashTranslator {
     public:
         template<typename T> static unsigned hash(const T& key) { return HashFunctions::hash(key); }
-        template<typename T> static bool equal(const T& a, const T& b) { return HashFunctions::equal(a, b); }
+        template<typename T, typename U> static bool equal(const T& a, const U& b) { return HashFunctions::equal(a, b); }
         template<typename T, typename U> static void translate(T& location, const U&, const T& value) { location = value; }
     };
 

Modified: trunk/Source/WTF/wtf/HashTraits.h (149601 => 149602)


--- trunk/Source/WTF/wtf/HashTraits.h	2013-05-06 16:37:41 UTC (rev 149601)
+++ trunk/Source/WTF/wtf/HashTraits.h	2013-05-06 16:41:38 UTC (rev 149602)
@@ -138,10 +138,15 @@
     };
 
     template<typename P> struct HashTraits<RefPtr<P> > : SimpleClassHashTraits<RefPtr<P> > {
+        static P* emptyValue() { return 0; }
+
         typedef PassRefPtr<P> PassInType;
         static void store(PassRefPtr<P> value, RefPtr<P>& storage) { storage = value; }
 
-        // FIXME: We should change PassOutType to PassRefPtr for better performance.
+        typedef PassRefPtr<P> PassOutType;
+        static PassRefPtr<P> passOut(RefPtr<P>& value) { return value.release(); }
+        static PassRefPtr<P> passOut(P* value) { return value; }
+
         // FIXME: We should consider changing PeekType to a raw pointer for better performance,
         // but then callers won't need to call get; doing so will require updating many call sites.
     };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to