<!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>[51566] 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/51566">51566</a></dd>
<dt>Author</dt> <dd>snej@chromium.org</dd>
<dt>Date</dt> <dd>2009-12-01 16:05:30 -0800 (Tue, 01 Dec 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>JavaScriptCore: Added variants of find/contains/add that allow a foreign key type to be used.
This will allow AtomicString-keyed maps to be queried by C string without
having to create a temporary AtomicString (see HTTPHeaderMap.)
The code for this is adapted from the equivalent in HashSet.h.

WebCore: Add convenience methods to Element and QualifiedName that take
char* instead of AtomicString, in preparation for removing the
implicit conversion between the two types (30187).
https://bugs.webkit.org/show_bug.cgi?id=31749

Reviewed by Darin Adler.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJavaScriptCoreChangeLog">trunk/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkJavaScriptCorewtfHashMaph">trunk/JavaScriptCore/wtf/HashMap.h</a></li>
<li><a href="#trunkJavaScriptCorewtfHashSeth">trunk/JavaScriptCore/wtf/HashSet.h</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoredomElementcpp">trunk/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkWebCoredomElementh">trunk/WebCore/dom/Element.h</a></li>
<li><a href="#trunkWebCoredomQualifiedNamecpp">trunk/WebCore/dom/QualifiedName.cpp</a></li>
<li><a href="#trunkWebCoredomQualifiedNameh">trunk/WebCore/dom/QualifiedName.h</a></li>
<li><a href="#trunkWebCoreplatformnetworkHTTPHeaderMapcpp">trunk/WebCore/platform/network/HTTPHeaderMap.cpp</a></li>
<li><a href="#trunkWebCoreplatformnetworkHTTPHeaderMaph">trunk/WebCore/platform/network/HTTPHeaderMap.h</a></li>
<li><a href="#trunkWebCoreplatformnetworkResourceRequestBasecpp">trunk/WebCore/platform/network/ResourceRequestBase.cpp</a></li>
<li><a href="#trunkWebCoreplatformnetworkResourceRequestBaseh">trunk/WebCore/platform/network/ResourceRequestBase.h</a></li>
<li><a href="#trunkWebCoreplatformnetworkResourceResponseBasecpp">trunk/WebCore/platform/network/ResourceResponseBase.cpp</a></li>
<li><a href="#trunkWebCoreplatformnetworkResourceResponseBaseh">trunk/WebCore/platform/network/ResourceResponseBase.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/ChangeLog (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/ChangeLog        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/JavaScriptCore/ChangeLog        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2009-12-01  Jens Alfke  &lt;snej@chromium.org&gt;
+
+        Reviewed by Darin Adler.
+
+        Added variants of find/contains/add that allow a foreign key type to be used.
+        This will allow AtomicString-keyed maps to be queried by C string without
+        having to create a temporary AtomicString (see HTTPHeaderMap.)
+        The code for this is adapted from the equivalent in HashSet.h.
+
+        * wtf/HashMap.h:
+        (WTF::HashMap::find):
+        (WTF::HashMap::contains):
+        (WTF::HashMap::add):
+        * wtf/HashSet.h: Changed &quot;method&quot; to &quot;function member&quot; in a comment.
+
</ins><span class="cx"> 2009-12-01  Gustavo Noronha Silva  &lt;gustavo.noronha@collabora.co.uk&gt;
</span><span class="cx"> 
</span><span class="cx">         Revert 51551 because it broke GTK+.
</span></span></pre></div>
<a id="trunkJavaScriptCorewtfHashMaph"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/wtf/HashMap.h (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/wtf/HashMap.h        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/JavaScriptCore/wtf/HashMap.h        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -83,6 +83,23 @@
</span><span class="cx"> 
</span><span class="cx">         MappedType take(const KeyType&amp;); // efficient combination of get with remove
</span><span class="cx"> 
</span><ins>+        // An alternate version of find() that finds the object by hashing and comparing
+        // with some other type, to avoid the cost of type conversion. HashTranslator
+        // must have the following function members:
+        //   static unsigned hash(const T&amp;);
+        //   static bool equal(const ValueType&amp;, const T&amp;);
+        template&lt;typename T, typename HashTranslator&gt; iterator find(const T&amp;);
+        template&lt;typename T, typename HashTranslator&gt; const_iterator find(const T&amp;) const;
+        template&lt;typename T, typename HashTranslator&gt; bool contains(const T&amp;) const;
+
+        // An alternate version of add() that finds the object by hashing and comparing
+        // with some other type, to avoid the cost of type conversion if the object is already
+        // in the table. HashTranslator must have the following function members:
+        //   static unsigned hash(const T&amp;);
+        //   static bool equal(const ValueType&amp;, const T&amp;);
+        //   static translate(ValueType&amp;, const T&amp;, unsigned hashCode);
+        template&lt;typename T, typename HashTranslator&gt; pair&lt;iterator, bool&gt; add(const T&amp;, const MappedType&amp;);
+
</ins><span class="cx">     private:
</span><span class="cx">         pair&lt;iterator, bool&gt; inlineAdd(const KeyType&amp;, const MappedType&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -107,6 +124,19 @@
</span><span class="cx">         }
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+    template&lt;typename ValueType, typename ValueTraits, typename T, typename Translator&gt;
+    struct HashMapTranslatorAdapter {
+        typedef typename ValueType::first_type KeyType;
+        typedef typename ValueType::second_type MappedType;
+
+        static unsigned hash(const T&amp; key) { return Translator::hash(key); }
+        static bool equal(const KeyType&amp; a, const T&amp; b) { return Translator::equal(a, b); }
+        static void translate(ValueType&amp; location, const T&amp; key, const MappedType&amp;, unsigned hashCode)
+        {
+            Translator::translate(location.first, key, hashCode);
+        }
+    };
+
</ins><span class="cx">     template&lt;typename T, typename U, typename V, typename W, typename X&gt;
</span><span class="cx">     inline void HashMap&lt;T, U, V, W, X&gt;::swap(HashMap&amp; other)
</span><span class="cx">     {
</span><span class="lines">@@ -174,6 +204,33 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     template&lt;typename T, typename U, typename V, typename W, typename X&gt;
</span><ins>+    template&lt;typename TYPE, typename HashTranslator&gt;
+    inline typename HashMap&lt;T, U, V, W, X&gt;::iterator
+    HashMap&lt;T, U, V, W, X&gt;::find(const TYPE&amp; value)
+    {
+        typedef HashMapTranslatorAdapter&lt;ValueType, ValueTraits, TYPE, HashTranslator&gt; Adapter;
+        return m_impl.template find&lt;TYPE, Adapter&gt;(value);
+    }
+
+    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
+    template&lt;typename TYPE, typename HashTranslator&gt;
+    inline typename HashMap&lt;T, U, V, W, X&gt;::const_iterator 
+    HashMap&lt;T, U, V, W, X&gt;::find(const TYPE&amp; value) const
+    {
+        typedef HashMapTranslatorAdapter&lt;ValueType, ValueTraits, TYPE, HashTranslator&gt; Adapter;
+        return m_impl.template find&lt;TYPE, Adapter&gt;(value);
+    }
+
+    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
+    template&lt;typename TYPE, typename HashTranslator&gt;
+    inline bool
+    HashMap&lt;T, U, V, W, X&gt;::contains(const TYPE&amp; value) const
+    {
+        typedef HashMapTranslatorAdapter&lt;ValueType, ValueTraits, TYPE, HashTranslator&gt; Adapter;
+        return m_impl.template contains&lt;TYPE, Adapter&gt;(value);
+    }
+
+    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
</ins><span class="cx">     inline pair&lt;typename HashMap&lt;T, U, V, W, X&gt;::iterator, bool&gt;
</span><span class="cx">     HashMap&lt;T, U, V, W, X&gt;::inlineAdd(const KeyType&amp; key, const MappedType&amp; mapped) 
</span><span class="cx">     {
</span><span class="lines">@@ -194,7 +251,16 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     template&lt;typename T, typename U, typename V, typename W, typename X&gt;
</span><ins>+    template&lt;typename TYPE, typename HashTranslator&gt;
</ins><span class="cx">     pair&lt;typename HashMap&lt;T, U, V, W, X&gt;::iterator, bool&gt;
</span><ins>+    HashMap&lt;T, U, V, W, X&gt;::add(const TYPE&amp; key, const MappedType&amp; value)
+    {
+        typedef HashMapTranslatorAdapter&lt;ValueType, ValueTraits, TYPE, HashTranslator&gt; Adapter;
+        return m_impl.template addPassingHashCode&lt;TYPE, MappedType, Adapter&gt;(key, value);
+    }
+
+    template&lt;typename T, typename U, typename V, typename W, typename X&gt;
+    pair&lt;typename HashMap&lt;T, U, V, W, X&gt;::iterator, bool&gt;
</ins><span class="cx">     HashMap&lt;T, U, V, W, X&gt;::add(const KeyType&amp; key, const MappedType&amp; mapped)
</span><span class="cx">     {
</span><span class="cx">         return inlineAdd(key, mapped);
</span></span></pre></div>
<a id="trunkJavaScriptCorewtfHashSeth"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/wtf/HashSet.h (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/wtf/HashSet.h        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/JavaScriptCore/wtf/HashSet.h        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx"> 
</span><span class="cx">         // An alternate version of add() that finds the object by hashing and comparing
</span><span class="cx">         // with some other type, to avoid the cost of type conversion if the object is already
</span><del>-        // in the table. HashTranslator must have the following methods:
</del><ins>+        // in the table. HashTranslator must have the following function members:
</ins><span class="cx">         //   static unsigned hash(const T&amp;);
</span><span class="cx">         //   static bool equal(const ValueType&amp;, const T&amp;);
</span><span class="cx">         //   static translate(ValueType&amp;, const T&amp;, unsigned hashCode);
</span></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/ChangeLog        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2009-12-01  Jens Alfke  &lt;snej@chromium.org&gt;
+
+        Reviewed by Darin Adler.
+
+        Add convenience methods to Element and QualifiedName that take
+        char* instead of AtomicString, in preparation for removing the
+        implicit conversion between the two types (30187).
+        https://bugs.webkit.org/show_bug.cgi?id=31749
+
+        * dom/Element.cpp:
+        (WebCore::Element::setCStringAttribute):  Equivalent to setAttribute.
+        * dom/Element.h:
+        * dom/QualifiedName.cpp:
+        (WebCore::QualifiedName::init):  Shared impl of both constructors
+        (WebCore::QualifiedName::QualifiedName):  New c'tor taking char*.
+        * dom/QualifiedName.h:
+        * platform/network/HTTPHeaderMap.cpp:
+        (WebCore::CaseFoldingCStringTranslator):  Enables lookup by C string
+        (WebCore::HTTPHeaderMap::get):  New variant that takes C string
+        (WebCore::HTTPHeaderMap::contains):  New variant that takes C string
+        (WebCore::HTTPHeaderMap::add):  New variant that takes C string
+        * platform/network/HTTPHeaderMap.h:
+        (WebCore::HTTPHeaderMap::get):
+        (WebCore::HTTPHeaderMap::add):
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::httpHeaderField):  New variant that takes C string
+        * platform/network/ResourceRequestBase.h:
+        (WebCore::ResourceRequestBase::setHTTPHeaderField):  Use symbolic names for headers
+        * platform/network/ResourceResponseBase.cpp:
+        (WebCore::ResourceResponseBase::httpHeaderField):  New variant that takes C string
+        * platform/network/ResourceResponseBase.h:
+
</ins><span class="cx"> 2009-12-01  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         More Windows build fix.
</span></span></pre></div>
<a id="trunkWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Element.cpp (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Element.cpp        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/dom/Element.cpp        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -136,6 +136,12 @@
</span><span class="cx">     ExceptionCode ec;
</span><span class="cx">     setAttribute(name, value, ec);
</span><span class="cx"> }
</span><ins>+    
+void Element::setCStringAttribute(const QualifiedName&amp; name, const char* cStringValue)
+{
+    ExceptionCode ec;
+    setAttribute(name, AtomicString(cStringValue), ec);
+}
</ins><span class="cx"> 
</span><span class="cx"> void Element::setBooleanAttribute(const QualifiedName&amp; name, bool b)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/Element.h (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/Element.h        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/dom/Element.h        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -167,6 +167,9 @@
</span><span class="cx">     // convenience methods which ignore exceptions
</span><span class="cx">     void setAttribute(const QualifiedName&amp;, const AtomicString&amp; value);
</span><span class="cx">     void setBooleanAttribute(const QualifiedName&amp; name, bool);
</span><ins>+    // Please don't use setCStringAttribute in performance-sensitive code;
+    // use a static AtomicString value instead to avoid the conversion overhead.
+    void setCStringAttribute(const QualifiedName&amp;, const char* cStringValue);
</ins><span class="cx"> 
</span><span class="cx">     virtual NamedNodeMap* attributes() const;
</span><span class="cx">     NamedNodeMap* attributes(bool readonly) const;
</span></span></pre></div>
<a id="trunkWebCoredomQualifiedNamecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/QualifiedName.cpp (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/QualifiedName.cpp        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/dom/QualifiedName.cpp        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx"> 
</span><span class="cx"> static QNameSet* gNameCache;
</span><span class="cx"> 
</span><del>-QualifiedName::QualifiedName(const AtomicString&amp; p, const AtomicString&amp; l, const AtomicString&amp; n)
</del><ins>+void QualifiedName::init(const AtomicString&amp; p, const AtomicString&amp; l, const AtomicString&amp; n)
</ins><span class="cx"> {
</span><span class="cx">     if (!gNameCache)
</span><span class="cx">         gNameCache = new QNameSet;
</span><span class="lines">@@ -62,6 +62,16 @@
</span><span class="cx">         m_impl-&gt;ref();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+QualifiedName::QualifiedName(const AtomicString&amp; p, const AtomicString&amp; l, const AtomicString&amp; n)
+{
+    init(p, l, n);
+}
+
+QualifiedName::QualifiedName(const AtomicString&amp; p, const char* l, const AtomicString&amp; n)
+{
+    init(p, AtomicString(l), n);
+}
+
</ins><span class="cx"> void QualifiedName::deref()
</span><span class="cx"> {
</span><span class="cx"> #ifdef QNAME_DEFAULT_CONSTRUCTOR
</span></span></pre></div>
<a id="trunkWebCoredomQualifiedNameh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/dom/QualifiedName.h (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/dom/QualifiedName.h        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/dom/QualifiedName.h        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     QualifiedName(const AtomicString&amp; prefix, const AtomicString&amp; localName, const AtomicString&amp; namespaceURI);
</span><ins>+    QualifiedName(const AtomicString&amp; prefix, const char* localName, const AtomicString&amp; namespaceURI);
</ins><span class="cx">     ~QualifiedName() { deref(); }
</span><span class="cx"> #ifdef QNAME_DEFAULT_CONSTRUCTOR
</span><span class="cx">     QualifiedName() : m_impl(0) { }
</span><span class="lines">@@ -88,6 +89,7 @@
</span><span class="cx">     static void init();
</span><span class="cx">     
</span><span class="cx"> private:
</span><ins>+    void init(const AtomicString&amp; prefix, const AtomicString&amp; localName, const AtomicString&amp; namespaceURI);
</ins><span class="cx">     void ref() const { m_impl-&gt;ref(); }
</span><span class="cx">     void deref();
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkWebCoreplatformnetworkHTTPHeaderMapcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/network/HTTPHeaderMap.cpp (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/network/HTTPHeaderMap.cpp        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/platform/network/HTTPHeaderMap.cpp        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -59,5 +59,41 @@
</span><span class="cx">         set(header.first, header.second);
</span><span class="cx">     }
</span><span class="cx"> }
</span><ins>+    
+// Adapter that allows the HashMap to take C strings as keys.
+struct CaseFoldingCStringTranslator {
+    static unsigned hash(const char* cString)
+    {
+        return CaseFoldingHash::hash(cString, strlen(cString));
+    }
+    
+    static bool equal(const AtomicString&amp; key, const char* cString)
+    {
+        return equalIgnoringCase(key, cString);
+    }
+    
+    static void translate(AtomicString&amp; location, const char* cString, unsigned /*hash*/)
+    {
+        location = AtomicString(cString);
+    }
+};
</ins><span class="cx"> 
</span><ins>+String HTTPHeaderMap::get(const char* name) const
+{
+    const_iterator i = find&lt;const char*, CaseFoldingCStringTranslator&gt;(name);
+    if (i == end())
+        return String();
+    return i-&gt;second;
+}
+    
+bool HTTPHeaderMap::contains(const char* name) const
+{
+    return find&lt;const char*, CaseFoldingCStringTranslator&gt;(name) != end();
+}
+
+pair&lt;HTTPHeaderMap::iterator, bool&gt; HTTPHeaderMap::add(const char* name, const String&amp; value)
+{
+    return HashMap&lt;AtomicString, String, CaseFoldingHash&gt;::add&lt;const char*, CaseFoldingCStringTranslator&gt;(name, value);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkWebCoreplatformnetworkHTTPHeaderMaph"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/network/HTTPHeaderMap.h (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/network/HTTPHeaderMap.h        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/platform/network/HTTPHeaderMap.h        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -45,6 +45,22 @@
</span><span class="cx">         std::auto_ptr&lt;CrossThreadHTTPHeaderMapData&gt; copyData() const;
</span><span class="cx"> 
</span><span class="cx">         void adopt(std::auto_ptr&lt;CrossThreadHTTPHeaderMapData&gt;);
</span><ins>+        
+        String get(const AtomicString&amp; name) const
+        {
+            return HashMap&lt;AtomicString, String, CaseFoldingHash&gt;::get(name);
+        }
+
+        pair&lt;iterator, bool&gt; add(const AtomicString&amp; name, const String&amp; value)
+        {
+            return HashMap&lt;AtomicString, String, CaseFoldingHash&gt;::add(name, value);
+        }
+
+        // Alternate accessors that are faster than converting the char* to AtomicString first.
+        bool contains(const char*) const;
+        String get(const char*) const;
+        pair&lt;iterator, bool&gt; add(const char* name, const String&amp; value);
+        
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkWebCoreplatformnetworkResourceRequestBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/network/ResourceRequestBase.cpp (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/network/ResourceRequestBase.cpp        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/platform/network/ResourceRequestBase.cpp        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -208,6 +208,13 @@
</span><span class="cx">     return m_httpHeaderFields.get(name);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String ResourceRequestBase::httpHeaderField(const char* name) const
+{
+    updateResourceRequest(); 
+    
+    return m_httpHeaderFields.get(name);
+}
+
</ins><span class="cx"> void ResourceRequestBase::setHTTPHeaderField(const AtomicString&amp; name, const String&amp; value)
</span><span class="cx"> {
</span><span class="cx">     updateResourceRequest(); 
</span><span class="lines">@@ -218,6 +225,11 @@
</span><span class="cx">         m_platformRequestUpdated = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ResourceRequestBase::setHTTPHeaderField(const char* name, const String&amp; value)
+{
+    setHTTPHeaderField(AtomicString(name), value);
+}
+
</ins><span class="cx"> void ResourceRequestBase::clearHTTPReferrer()
</span><span class="cx"> {
</span><span class="cx">     updateResourceRequest(); 
</span></span></pre></div>
<a id="trunkWebCoreplatformnetworkResourceRequestBaseh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/network/ResourceRequestBase.h (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/network/ResourceRequestBase.h        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/platform/network/ResourceRequestBase.h        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -79,7 +79,9 @@
</span><span class="cx">         
</span><span class="cx">         const HTTPHeaderMap&amp; httpHeaderFields() const;
</span><span class="cx">         String httpHeaderField(const AtomicString&amp; name) const;
</span><ins>+        String httpHeaderField(const char* name) const;
</ins><span class="cx">         void setHTTPHeaderField(const AtomicString&amp; name, const String&amp; value);
</span><ins>+        void setHTTPHeaderField(const char* name, const String&amp; value);
</ins><span class="cx">         void addHTTPHeaderField(const AtomicString&amp; name, const String&amp; value);
</span><span class="cx">         void addHTTPHeaderFields(const HTTPHeaderMap&amp; headerFields);
</span><span class="cx">         
</span></span></pre></div>
<a id="trunkWebCoreplatformnetworkResourceResponseBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/network/ResourceResponseBase.cpp (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/network/ResourceResponseBase.cpp        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/platform/network/ResourceResponseBase.cpp        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -239,6 +239,13 @@
</span><span class="cx">     return m_httpHeaderFields.get(name); 
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String ResourceResponseBase::httpHeaderField(const char* name) const
+{
+    lazyInit();
+
+    return m_httpHeaderFields.get(name); 
+}
+
</ins><span class="cx"> void ResourceResponseBase::setHTTPHeaderField(const AtomicString&amp; name, const String&amp; value)
</span><span class="cx"> {
</span><span class="cx">     lazyInit();
</span></span></pre></div>
<a id="trunkWebCoreplatformnetworkResourceResponseBaseh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/network/ResourceResponseBase.h (51565 => 51566)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/network/ResourceResponseBase.h        2009-12-01 23:59:54 UTC (rev 51565)
+++ trunk/WebCore/platform/network/ResourceResponseBase.h        2009-12-02 00:05:30 UTC (rev 51566)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx">     void setHTTPStatusText(const String&amp;);
</span><span class="cx">     
</span><span class="cx">     String httpHeaderField(const AtomicString&amp; name) const;
</span><ins>+    String httpHeaderField(const char* name) const;
</ins><span class="cx">     void setHTTPHeaderField(const AtomicString&amp; name, const String&amp; value);
</span><span class="cx">     const HTTPHeaderMap&amp; httpHeaderFields() const;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>