<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[174268] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/174268">174268</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2014-10-03 09:47:06 -0700 (Fri, 03 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove RefPtrHashMap
https://bugs.webkit.org/show_bug.cgi?id=137200

Reviewed by Darin Adler.

Source/WTF:

HashMap now has all the features of the RefPtr specialization of HashMap
(which lived in RefPtrHashMap.h) and is in fact more efficient when moving
items into it. For instance:

For HashMap&lt;RefPtr&lt;Foo&gt;, Bar&gt; map:

RefPtr&lt;Foo&gt; foo = ...;
map.add(WTF::move(foo), Bar());

will now not cause a ref() / deref(), but will successfully move the item in
without churn. The same is true if foo.release() was used.

* WTF.vcxproj/WTF.vcxproj:
* WTF.vcxproj/WTF.vcxproj.filters:
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
Remove references to RefPtrHashMap.h.

* wtf/RefPtrHashMap.h: Removed.

* wtf/HashMap.h:
Remove #include of RefPtrHashMap.h and add inlineGet to match the interface
exposed by the RefPtrHashMap specialization.

Tools:

* TestWebKitAPI/Tests/WTF/HashMap.cpp:
(TestWebKitAPI::TEST):
Add tests for using a HashMap with RefPtr keys, focusing on ensuring that
a minimum of refcount churn occurs.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFvcxprojWTFvcxproj">trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj</a></li>
<li><a href="#trunkSourceWTFWTFvcxprojWTFvcxprojfilters">trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWTFwtfCMakeListstxt">trunk/Source/WTF/wtf/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWTFwtfHashMaph">trunk/Source/WTF/wtf/HashMap.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWTFHashMapcpp">trunk/Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfRefPtrHashMaph">trunk/Source/WTF/wtf/RefPtrHashMap.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (174267 => 174268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-10-03 16:43:06 UTC (rev 174267)
+++ trunk/Source/WTF/ChangeLog        2014-10-03 16:47:06 UTC (rev 174268)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2014-09-28  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Remove RefPtrHashMap
+        https://bugs.webkit.org/show_bug.cgi?id=137200
+
+        Reviewed by Darin Adler.
+
+        HashMap now has all the features of the RefPtr specialization of HashMap
+        (which lived in RefPtrHashMap.h) and is in fact more efficient when moving
+        items into it. For instance:
+
+        For HashMap&lt;RefPtr&lt;Foo&gt;, Bar&gt; map:
+
+        RefPtr&lt;Foo&gt; foo = ...;
+        map.add(WTF::move(foo), Bar());
+
+        will now not cause a ref() / deref(), but will successfully move the item in
+        without churn. The same is true if foo.release() was used.
+
+        * WTF.vcxproj/WTF.vcxproj:
+        * WTF.vcxproj/WTF.vcxproj.filters:
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        Remove references to RefPtrHashMap.h.
+
+        * wtf/RefPtrHashMap.h: Removed.
+
+        * wtf/HashMap.h:
+        Remove #include of RefPtrHashMap.h and add inlineGet to match the interface
+        exposed by the RefPtrHashMap specialization.
+
</ins><span class="cx"> 2014-10-02  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add back debugging/testing code that I accidentally removed.
</span></span></pre></div>
<a id="trunkSourceWTFWTFvcxprojWTFvcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj (174267 => 174268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj        2014-10-03 16:43:06 UTC (rev 174267)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj        2014-10-03 16:47:06 UTC (rev 174268)
</span><span class="lines">@@ -257,7 +257,6 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\RefCounted.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\RefCountedLeakCounter.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\RefPtr.h&quot; /&gt;
</span><del>-    &lt;ClInclude Include=&quot;..\wtf\RefPtrHashMap.h&quot; /&gt;
</del><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\RetainPtr.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\RunLoop.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\SaturatedArithmetic.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWTFWTFvcxprojWTFvcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters (174267 => 174268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters        2014-10-03 16:43:06 UTC (rev 174267)
+++ trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters        2014-10-03 16:47:06 UTC (rev 174268)
</span><span class="lines">@@ -582,9 +582,6 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\RefPtr.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;wtf&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><del>-    &lt;ClInclude Include=&quot;..\wtf\RefPtrHashMap.h&quot;&gt;
-      &lt;Filter&gt;wtf&lt;/Filter&gt;
-    &lt;/ClInclude&gt;
</del><span class="cx">     &lt;ClInclude Include=&quot;..\wtf\RetainPtr.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;wtf&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (174267 => 174268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2014-10-03 16:43:06 UTC (rev 174267)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2014-10-03 16:47:06 UTC (rev 174268)
</span><span class="lines">@@ -205,7 +205,6 @@
</span><span class="cx">                 A8A4741A151A825B004123FF /* RefCountedLeakCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A47301151A825B004123FF /* RefCountedLeakCounter.cpp */; };
</span><span class="cx">                 A8A4741B151A825B004123FF /* RefCountedLeakCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47302151A825B004123FF /* RefCountedLeakCounter.h */; };
</span><span class="cx">                 A8A4741C151A825B004123FF /* RefPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47303151A825B004123FF /* RefPtr.h */; };
</span><del>-                A8A4741D151A825B004123FF /* RefPtrHashMap.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47304151A825B004123FF /* RefPtrHashMap.h */; };
</del><span class="cx">                 A8A4741E151A825B004123FF /* RetainPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47305151A825B004123FF /* RetainPtr.h */; };
</span><span class="cx">                 A8A4741F151A825B004123FF /* SegmentedVector.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47306151A825B004123FF /* SegmentedVector.h */; };
</span><span class="cx">                 A8A47420151A825B004123FF /* SentinelLinkedList.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47307151A825B004123FF /* SentinelLinkedList.h */; };
</span><span class="lines">@@ -497,7 +496,6 @@
</span><span class="cx">                 A8A47301151A825B004123FF /* RefCountedLeakCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefCountedLeakCounter.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A8A47302151A825B004123FF /* RefCountedLeakCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefCountedLeakCounter.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A8A47303151A825B004123FF /* RefPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefPtr.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                A8A47304151A825B004123FF /* RefPtrHashMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefPtrHashMap.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 A8A47305151A825B004123FF /* RetainPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RetainPtr.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A8A47306151A825B004123FF /* SegmentedVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SegmentedVector.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A8A47307151A825B004123FF /* SentinelLinkedList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SentinelLinkedList.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -831,7 +829,6 @@
</span><span class="cx">                                 A8A47301151A825B004123FF /* RefCountedLeakCounter.cpp */,
</span><span class="cx">                                 A8A47302151A825B004123FF /* RefCountedLeakCounter.h */,
</span><span class="cx">                                 A8A47303151A825B004123FF /* RefPtr.h */,
</span><del>-                                A8A47304151A825B004123FF /* RefPtrHashMap.h */,
</del><span class="cx">                                 A8A47305151A825B004123FF /* RetainPtr.h */,
</span><span class="cx">                                 2CDED0F118115C85004DBA70 /* RunLoop.cpp */,
</span><span class="cx">                                 2CDED0F218115C85004DBA70 /* RunLoop.h */,
</span><span class="lines">@@ -1153,7 +1150,6 @@
</span><span class="cx">                                 A8A47419151A825B004123FF /* RefCountedArray.h in Headers */,
</span><span class="cx">                                 A8A4741B151A825B004123FF /* RefCountedLeakCounter.h in Headers */,
</span><span class="cx">                                 A8A4741C151A825B004123FF /* RefPtr.h in Headers */,
</span><del>-                                A8A4741D151A825B004123FF /* RefPtrHashMap.h in Headers */,
</del><span class="cx">                                 A8A4741E151A825B004123FF /* RetainPtr.h in Headers */,
</span><span class="cx">                                 2CDED0F418115C85004DBA70 /* RunLoop.h in Headers */,
</span><span class="cx">                                 1469419216EAAF6D0024E146 /* RunLoopTimer.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/CMakeLists.txt (174267 => 174268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/CMakeLists.txt        2014-10-03 16:43:06 UTC (rev 174267)
+++ trunk/Source/WTF/wtf/CMakeLists.txt        2014-10-03 16:47:06 UTC (rev 174268)
</span><span class="lines">@@ -83,7 +83,6 @@
</span><span class="cx">     RefCounted.h
</span><span class="cx">     RefCountedLeakCounter.h
</span><span class="cx">     RefPtr.h
</span><del>-    RefPtrHashMap.h
</del><span class="cx">     RetainPtr.h
</span><span class="cx">     RunLoop.h
</span><span class="cx">     SHA1.h
</span></span></pre></div>
<a id="trunkSourceWTFwtfHashMaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/HashMap.h (174267 => 174268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/HashMap.h        2014-10-03 16:43:06 UTC (rev 174267)
+++ trunk/Source/WTF/wtf/HashMap.h        2014-10-03 16:47:06 UTC (rev 174268)
</span><span class="lines">@@ -147,6 +147,7 @@
</span><span class="cx">     template&lt;typename K = KeyType&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, iterator&gt;::type find(typename GetPtrHelper&lt;K&gt;::PtrType);
</span><span class="cx">     template&lt;typename K = KeyType&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, const_iterator&gt;::type find(typename GetPtrHelper&lt;K&gt;::PtrType) const;
</span><span class="cx">     template&lt;typename K = KeyType&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, bool&gt;::type contains(typename GetPtrHelper&lt;K&gt;::PtrType) const;
</span><ins>+    template&lt;typename K = KeyType&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, MappedPeekType&gt;::type inlineGet(typename GetPtrHelper&lt;K&gt;::PtrType) const;
</ins><span class="cx">     template&lt;typename K = KeyType&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, MappedPeekType&gt;::type get(typename GetPtrHelper&lt;K&gt;::PtrType) const;
</span><span class="cx">     template&lt;typename K = KeyType&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, bool&gt;::type remove(typename GetPtrHelper&lt;K&gt;::PtrType);
</span><span class="cx">     template&lt;typename K = KeyType&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, MappedType&gt;::type take(typename GetPtrHelper&lt;K&gt;::PtrType);
</span><span class="lines">@@ -416,7 +417,7 @@
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename T, typename U, typename V, typename W, typename X&gt;
</span><span class="cx"> template&lt;typename K&gt;
</span><del>-inline auto HashMap&lt;T, U, V, W, X&gt;::get(typename GetPtrHelper&lt;K&gt;::PtrType key) const -&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, MappedPeekType&gt;::type
</del><ins>+inline auto HashMap&lt;T, U, V, W, X&gt;::inlineGet(typename GetPtrHelper&lt;K&gt;::PtrType key) const -&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, MappedPeekType&gt;::type
</ins><span class="cx"> {
</span><span class="cx">     KeyValuePairType* entry = const_cast&lt;HashTableType&amp;&gt;(m_impl).template lookup&lt;HashMapTranslator&lt;KeyValuePairTraits, HashFunctions&gt;&gt;(key);
</span><span class="cx">     if (!entry)
</span><span class="lines">@@ -426,6 +427,13 @@
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename T, typename U, typename V, typename W, typename X&gt;
</span><span class="cx"> template&lt;typename K&gt;
</span><ins>+auto HashMap&lt;T, U, V, W, X&gt;::get(typename GetPtrHelper&lt;K&gt;::PtrType key) const -&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, MappedPeekType&gt;::type
+{
+    return inlineGet(key);
+}
+
+template&lt;typename T, typename U, typename V, typename W, typename X&gt;
+template&lt;typename K&gt;
</ins><span class="cx"> inline auto HashMap&lt;T, U, V, W, X&gt;::remove(typename GetPtrHelper&lt;K&gt;::PtrType key) -&gt; typename std::enable_if&lt;IsSmartPtr&lt;K&gt;::value, bool&gt;::type
</span><span class="cx"> {
</span><span class="cx">     return remove(find(key));
</span><span class="lines">@@ -521,6 +529,4 @@
</span><span class="cx"> 
</span><span class="cx"> using WTF::HashMap;
</span><span class="cx"> 
</span><del>-#include &lt;wtf/RefPtrHashMap.h&gt;
-
</del><span class="cx"> #endif /* WTF_HashMap_h */
</span></span></pre></div>
<a id="trunkSourceWTFwtfRefPtrHashMaph"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WTF/wtf/RefPtrHashMap.h (174267 => 174268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/RefPtrHashMap.h        2014-10-03 16:43:06 UTC (rev 174267)
+++ trunk/Source/WTF/wtf/RefPtrHashMap.h        2014-10-03 16:47:06 UTC (rev 174268)
</span><span class="lines">@@ -1,334 +0,0 @@
</span><del>-/*
- * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2013 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef RefPtrHashMap_h
-#define RefPtrHashMap_h
-
-namespace WTF {
-
-    // This specialization is a copy of HashMap for use with RefPtr keys, with overloaded functions
-    // to allow for lookup by pointer instead of RefPtr, avoiding ref-count churn.
-    
-     // FIXME: Find a way to do this with traits that doesn't require a copy of the HashMap template.
-    
-    template&lt;typename T, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg&gt;
-    class HashMap&lt;RefPtr&lt;T&gt;, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg&gt; {
-        WTF_MAKE_FAST_ALLOCATED;
-    private:
-        typedef KeyTraitsArg KeyTraits;
-        typedef MappedTraitsArg MappedTraits;
-        typedef KeyValuePairHashTraits&lt;KeyTraits, MappedTraits&gt; ValueTraits;
-
-    public:
-        typedef typename KeyTraits::TraitType KeyType;
-        typedef T* RawKeyType;
-        typedef typename MappedTraits::TraitType MappedType;
-        typedef typename ValueTraits::TraitType ValueType;
-
-    private:
-        typedef typename MappedTraits::PeekType MappedPeekType;
-        
-        typedef HashArg HashFunctions;
-
-        typedef HashTable&lt;KeyType, ValueType, KeyValuePairKeyExtractor&lt;ValueType&gt;,
-            HashFunctions, ValueTraits, KeyTraits&gt; HashTableType;
-
-        typedef HashMapTranslator&lt;ValueTraits, HashFunctions&gt;
-            Translator;
-
-    public:
-        typedef HashTableIteratorAdapter&lt;HashTableType, ValueType&gt; iterator;
-        typedef HashTableConstIteratorAdapter&lt;HashTableType, ValueType&gt; const_iterator;
-        typedef typename HashTableType::AddResult AddResult;
-
-        void swap(HashMap&amp;);
-
-        int size() const;
-        int capacity() const;
-        bool isEmpty() const;
-
-        // iterators iterate over pairs of keys and values
-        iterator begin();
-        iterator end();
-        const_iterator begin() const;
-        const_iterator end() const;
-
-        IteratorRange&lt;typename iterator::Keys&gt; keys() { return makeIteratorRange(begin().keys(), end().keys()); }
-        const IteratorRange&lt;typename const_iterator::Keys&gt; keys() const { return makeIteratorRange(begin().keys(), end().keys()); }
-
-        IteratorRange&lt;typename iterator::Values&gt; values() { return makeIteratorRange(begin().values(), end().values()); }
-        const IteratorRange&lt;typename const_iterator::Values&gt; values() const { return makeIteratorRange(begin().values(), end().values()); }
-
-        iterator find(const KeyType&amp;);
-        iterator find(RawKeyType);
-        const_iterator find(const KeyType&amp;) const;
-        const_iterator find(RawKeyType) const;
-        bool contains(const KeyType&amp;) const;
-        bool contains(RawKeyType) const;
-        MappedPeekType get(const KeyType&amp;) const;
-        MappedPeekType get(RawKeyType) const;
-        MappedPeekType inlineGet(RawKeyType) const;
-
-        // replaces value but not key if key is already present
-        // return value is a pair of the iterator to the key location, 
-        // and a boolean that's true if a new value was actually added
-        template&lt;typename V&gt; AddResult set(const KeyType&amp;, V&amp;&amp;);
-        template&lt;typename V&gt; AddResult set(RawKeyType, V&amp;&amp;);
-
-        // does nothing if key is already present
-        // return value is a pair of the iterator to the key location, 
-        // and a boolean that's true if a new value was actually added
-        template&lt;typename V&gt; AddResult add(const KeyType&amp;, V&amp;&amp;);
-        template&lt;typename V&gt; AddResult add(RawKeyType, V&amp;&amp;);
-
-        bool remove(const KeyType&amp;);
-        bool remove(RawKeyType);
-        bool remove(iterator);
-        void clear();
-
-        MappedType take(const KeyType&amp;); // efficient combination of get with remove
-        MappedType take(RawKeyType); // efficient combination of get with remove
-
-    private:
-        template&lt;typename V&gt;
-        AddResult inlineAdd(const KeyType&amp;, V&amp;&amp;);
-
-        template&lt;typename V&gt;
-        AddResult inlineAdd(RawKeyType, V&amp;&amp;);
-
-        HashTableType m_impl;
-    };
-    
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline void HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::swap(HashMap&amp; other)
-    {
-        m_impl.swap(other.m_impl); 
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline int HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::size() const
-    {
-        return m_impl.size(); 
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline int HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::capacity() const
-    { 
-        return m_impl.capacity(); 
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline bool HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::isEmpty() const
-    {
-        return m_impl.isEmpty();
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::iterator HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::begin()
-    {
-        return m_impl.begin();
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::iterator HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::end()
-    {
-        return m_impl.end();
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::const_iterator HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::begin() const
-    {
-        return m_impl.begin();
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::const_iterator HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::end() const
-    {
-        return m_impl.end();
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::iterator HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::find(const KeyType&amp; key)
-    {
-        return m_impl.find(key);
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::iterator HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::find(RawKeyType key)
-    {
-        return m_impl.template find&lt;Translator&gt;(key);
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::const_iterator HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::find(const KeyType&amp; key) const
-    {
-        return m_impl.find(key);
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::const_iterator HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::find(RawKeyType key) const
-    {
-        return m_impl.template find&lt;Translator&gt;(key);
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline bool HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::contains(const KeyType&amp; key) const
-    {
-        return m_impl.contains(key);
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline bool HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::contains(RawKeyType key) const
-    {
-        return m_impl.template contains&lt;Translator&gt;(key);
-    }
-
-    template&lt;typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg&gt;
-    template&lt;typename V&gt;
-    auto HashMap&lt;RefPtr&lt;KeyArg&gt;, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg&gt;::inlineAdd(const KeyType&amp; key, V&amp;&amp; mapped) -&gt; AddResult
-    {
-        return m_impl.template add&lt;Translator&gt;(key, std::forward&lt;V&gt;(mapped));
-    }
-
-    template&lt;typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg&gt;
-    template&lt;typename V&gt;
-    auto HashMap&lt;RefPtr&lt;KeyArg&gt;, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg&gt;::inlineAdd(RawKeyType key, V&amp;&amp; mapped) -&gt; AddResult
-    {
-        return m_impl.template add&lt;Translator&gt;(key, std::forward&lt;V&gt;(mapped));
-    }
-
-    template&lt;typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg&gt;
-    template&lt;typename V&gt;
-    auto HashMap&lt;RefPtr&lt;KeyArg&gt;, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg&gt;::set(const KeyType&amp; key, V&amp;&amp; value) -&gt; AddResult
-    {
-        AddResult result = inlineAdd(key, std::forward&lt;V&gt;(value));
-        if (!result.isNewEntry) {
-            // The inlineAdd call above found an existing hash table entry; we need to set the mapped value.
-            result.iterator-&gt;value = std::forward&lt;V&gt;(value);
-        }
-        return result;
-    }
-
-    template&lt;typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg&gt;
-    template&lt;typename V&gt;
-    auto HashMap&lt;RefPtr&lt;KeyArg&gt;, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg&gt;::set(RawKeyType key, V&amp;&amp; value) -&gt; AddResult
-    {
-        AddResult result = inlineAdd(key, std::forward&lt;V&gt;(value));
-        if (!result.isNewEntry) {
-            // The inlineAdd call above found an existing hash table entry; we need to set the mapped value.
-            result.iterator-&gt;value = std::forward&lt;V&gt;(value);
-        }
-        return result;
-    }
-
-    template&lt;typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg&gt;
-    template&lt;typename V&gt;
-    auto HashMap&lt;RefPtr&lt;KeyArg&gt;, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg&gt;::add(const KeyType&amp; key, V&amp;&amp; value) -&gt; AddResult
-    {
-        return inlineAdd(key, std::forward&lt;V&gt;(value));
-    }
-
-    template&lt;typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg&gt;
-    template&lt;typename V&gt;
-    auto HashMap&lt;RefPtr&lt;KeyArg&gt;, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg&gt;::add(RawKeyType key, V&amp;&amp; value) -&gt; AddResult
-    {
-        return inlineAdd(key, std::forward&lt;V&gt;(value));
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename MappedTraits&gt;
-    typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, MappedTraits&gt;::MappedPeekType
-    HashMap&lt;RefPtr&lt;T&gt;, U, V, W, MappedTraits&gt;::get(const KeyType&amp; key) const
-    {
-        ValueType* entry = const_cast&lt;HashTableType&amp;&gt;(m_impl).lookup(key);
-        if (!entry)
-            return MappedTraits::peek(MappedTraits::emptyValue());
-        return MappedTraits::peek(entry-&gt;value);
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename MappedTraits&gt;
-    typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, MappedTraits&gt;::MappedPeekType
-    inline HashMap&lt;RefPtr&lt;T&gt;, U, V, W, MappedTraits&gt;::inlineGet(RawKeyType key) const
-    {
-        ValueType* entry = const_cast&lt;HashTableType&amp;&gt;(m_impl).template lookup&lt;Translator&gt;(key);
-        if (!entry)
-            return MappedTraits::peek(MappedTraits::emptyValue());
-        return MappedTraits::peek(entry-&gt;value);
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename MappedTraits&gt;
-    typename HashMap&lt;RefPtr&lt;T&gt;, U, V, W, MappedTraits&gt;::MappedPeekType
-    HashMap&lt;RefPtr&lt;T&gt;, U, V, W, MappedTraits&gt;::get(RawKeyType key) const
-    {
-        return inlineGet(key);
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline bool HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::remove(iterator it)
-    {
-        if (it.m_impl == m_impl.end())
-            return false;
-        m_impl.internalCheckTableConsistency();
-        m_impl.removeWithoutEntryConsistencyCheck(it.m_impl);
-        return true;
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline bool HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::remove(const KeyType&amp; key)
-    {
-        return remove(find(key));
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline bool HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::remove(RawKeyType key)
-    {
-        return remove(find(key));
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
-    inline void HashMap&lt;RefPtr&lt;T&gt;, U, V, W, X&gt;::clear()
-    {
-        m_impl.clear();
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename MappedTraits&gt;
-    auto HashMap&lt;RefPtr&lt;T&gt;, U, V, W, MappedTraits&gt;::take(const KeyType&amp; key) -&gt; MappedType
-    {
-        iterator it = find(key);
-        if (it == end())
-            return MappedTraits::emptyValue();
-        MappedType value = WTF::move(it-&gt;value);
-        remove(it);
-        return value;
-    }
-
-    template&lt;typename T, typename U, typename V, typename W, typename MappedTraits&gt;
-    auto HashMap&lt;RefPtr&lt;T&gt;, U, V, W, MappedTraits&gt;::take(RawKeyType key) -&gt; MappedType
-    {
-        iterator it = find(key);
-        if (it == end())
-            return MappedTraits::emptyValue();
-        MappedType value = WTF::move(it-&gt;value);
-        remove(it);
-        return value;
-    }
-
-} // namespace WTF
-
-#endif // RefPtrHashMap_h
</del></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (174267 => 174268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-10-03 16:43:06 UTC (rev 174267)
+++ trunk/Tools/ChangeLog        2014-10-03 16:47:06 UTC (rev 174268)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-09-28  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Remove RefPtrHashMap
+        https://bugs.webkit.org/show_bug.cgi?id=137200
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/Tests/WTF/HashMap.cpp:
+        (TestWebKitAPI::TEST):
+        Add tests for using a HashMap with RefPtr keys, focusing on ensuring that
+        a minimum of refcount churn occurs.
+
</ins><span class="cx"> 2014-10-03  Eva Balazsfalvi  &lt;evab.u-szeged@partner.samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove workarounds for versions of Python before 2.7
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFHashMapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp (174267 => 174268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp        2014-10-03 16:43:06 UTC (rev 174267)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp        2014-10-03 16:47:06 UTC (rev 174268)
</span><span class="lines">@@ -27,11 +27,12 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Counters.h&quot;
</span><span class="cx"> #include &quot;MoveOnly.h&quot;
</span><ins>+#include &quot;RefLogger.h&quot;
</ins><span class="cx"> #include &lt;string&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><del>-#include &lt;wtf/text/StringHash.h&gt;
</del><span class="cx"> #include &lt;wtf/OwnPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/PassOwnPtr.h&gt;
</span><ins>+#include &lt;wtf/text/StringHash.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx"> 
</span><span class="lines">@@ -386,4 +387,222 @@
</span><span class="cx">     EXPECT_EQ(1u, ConstructorDestructorCounter::destructionCount);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(WTF_HashMap, RefPtrKey_Add)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.add(ptr, 0);
+
+    ASSERT_STREQ(&quot;ref(a) ref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_AddUsingRelease)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.add(ptr.release(), 0);
+
+    EXPECT_STREQ(&quot;ref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_AddUsingMove)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.add(WTF::move(ptr), 0);
+
+    EXPECT_STREQ(&quot;ref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_AddUsingRaw)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.add(ptr.get(), 0);
+
+    EXPECT_STREQ(&quot;ref(a) ref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_AddKeyAlreadyPresent)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+
+    {
+        RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+        map.add(ptr, 0);
+    }
+
+    EXPECT_STREQ(&quot;ref(a) ref(a) deref(a) &quot;, takeLogStr().c_str());
+
+    {
+        RefPtr&lt;RefLogger&gt; ptr2(&amp;a);
+        auto addResult = map.add(ptr2, 0);
+        EXPECT_EQ(false, addResult.isNewEntry);
+    }
+
+    EXPECT_STREQ(&quot;ref(a) deref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_AddUsingReleaseKeyAlreadyPresent)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+
+    {
+        RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+        map.add(ptr, 0);
+    }
+
+    EXPECT_STREQ(&quot;ref(a) ref(a) deref(a) &quot;, takeLogStr().c_str());
+
+    {
+        RefPtr&lt;RefLogger&gt; ptr2(&amp;a);
+        auto addResult = map.add(ptr2.release(), 0);
+        EXPECT_EQ(false, addResult.isNewEntry);
+    }
+
+    EXPECT_STREQ(&quot;ref(a) deref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_AddUsingMoveKeyAlreadyPresent)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+
+    {
+        RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+        map.add(ptr, 0);
+    }
+
+    EXPECT_STREQ(&quot;ref(a) ref(a) deref(a) &quot;, takeLogStr().c_str());
+
+    {
+        RefPtr&lt;RefLogger&gt; ptr2(&amp;a);
+        auto addResult = map.add(WTF::move(ptr2), 0);
+        EXPECT_EQ(false, addResult.isNewEntry);
+    }
+
+    EXPECT_STREQ(&quot;ref(a) deref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_Set)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.set(ptr, 0);
+
+    ASSERT_STREQ(&quot;ref(a) ref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_SetUsingRelease)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.set(ptr.release(), 0);
+
+    EXPECT_STREQ(&quot;ref(a) &quot;, takeLogStr().c_str());
+}
+
+
+TEST(WTF_HashMap, RefPtrKey_SetUsingMove)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.set(WTF::move(ptr), 0);
+
+    EXPECT_STREQ(&quot;ref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_SetUsingRaw)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.set(ptr.get(), 0);
+
+    EXPECT_STREQ(&quot;ref(a) ref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_SetKeyAlreadyPresent)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.set(ptr, 0);
+
+    EXPECT_STREQ(&quot;ref(a) ref(a) &quot;, takeLogStr().c_str());
+
+    {
+        RefPtr&lt;RefLogger&gt; ptr2(&amp;a);
+        auto addResult = map.set(ptr2, 1);
+        EXPECT_EQ(false, addResult.isNewEntry);
+        EXPECT_EQ(1, map.get(ptr.get()));
+    }
+
+    EXPECT_STREQ(&quot;ref(a) deref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_SetUsingReleaseKeyAlreadyPresent)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.set(ptr, 0);
+
+    EXPECT_STREQ(&quot;ref(a) ref(a) &quot;, takeLogStr().c_str());
+
+    {
+        RefPtr&lt;RefLogger&gt; ptr2(&amp;a);
+        auto addResult = map.set(ptr2.release(), 1);
+        EXPECT_EQ(false, addResult.isNewEntry);
+        EXPECT_EQ(1, map.get(ptr.get()));
+    }
+
+    EXPECT_STREQ(&quot;ref(a) deref(a) &quot;, takeLogStr().c_str());
+}
+
+TEST(WTF_HashMap, RefPtrKey_SetUsingMoveKeyAlreadyPresent)
+{
+    HashMap&lt;RefPtr&lt;RefLogger&gt;, int&gt; map;
+
+    DerivedRefLogger a(&quot;a&quot;);
+
+    RefPtr&lt;RefLogger&gt; ptr(&amp;a);
+    map.set(ptr, 0);
+
+    EXPECT_STREQ(&quot;ref(a) ref(a) &quot;, takeLogStr().c_str());
+
+    {
+        RefPtr&lt;RefLogger&gt; ptr2(&amp;a);
+        auto addResult = map.set(WTF::move(ptr2), 1);
+        EXPECT_EQ(false, addResult.isNewEntry);
+        EXPECT_EQ(1, map.get(ptr.get()));
+    }
+
+    EXPECT_STREQ(&quot;ref(a) deref(a) &quot;, takeLogStr().c_str());
+}
+
</ins><span class="cx"> } // namespace TestWebKitAPI
</span></span></pre>
</div>
</div>

</body>
</html>