<!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>[195356] trunk/Source</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/195356">195356</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-20 09:59:02 -0800 (Wed, 20 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Refactor AtomicStringKeyedMRUCache to be a generic LRU cache
https://bugs.webkit.org/show_bug.cgi?id=153109

Patch by Said Abou-Hallawa &lt;sabouhallawa@apple.com&gt; on 2016-01-20
Reviewed by Darin Adler.

Source/WebCore:

Replace the template specialization of AtomicStringKeyedMRUCache with
template derived from TinyLRUCachePolicy. Override the functions which
are needed for creating the values and the null value. Also replace the
static function which was returning a NeverDestroyed AtomicStringKeyedMRUCache
with a singleton function 'cache' inside the derived template.

* WebCore.xcodeproj/project.pbxproj:
* platform/text/AtomicStringKeyedMRUCache.h: Removed.
* platform/text/cf/HyphenationCF.cpp:
(WebCore::canHyphenate):
(WebCore::lastHyphenLocation):
(WebCore::AtomicStringKeyedMRUCache&lt;RetainPtr&lt;CFLocaleRef&gt;&gt;::createValueForNullKey): Deleted.
(WebCore::AtomicStringKeyedMRUCache&lt;RetainPtr&lt;CFLocaleRef&gt;&gt;::createValueForKey): Deleted.
(WebCore::cfLocaleCache): Deleted.
* platform/text/hyphen/HyphenationLibHyphen.cpp:
(WebCore::countLeadingSpaces):
(WebCore::lastHyphenLocation):
(WebCore::AtomicStringKeyedMRUCache&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;::createValueForNullKey): Deleted.
(WebCore::AtomicStringKeyedMRUCache&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;::createValueForKey): Deleted.
(WebCore::hyphenDictionaryCache): Deleted.

Source/WTF:

Refactor AtomicStringKeyedMRUCache, move it to WTF project and rename it
to be TinyLRUCache. Define another template and call it TinyLRUCachePolicy.
This one can be overridden for different keys and values. Its function is
creating the cached values.

* WTF.xcodeproj/project.pbxproj:
* wtf/TinyLRUCache.h: Added.
(WebCore::TinyLRUCachePolicy::isKeyNull):
(WebCore::TinyLRUCachePolicy::createValueForNullKey):
(WebCore::TinyLRUCachePolicy::createValueForKey):
(WebCore::TinyLRUCache::get):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformtextcfHyphenationCFcpp">trunk/Source/WebCore/platform/text/cf/HyphenationCF.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformtexthyphenHyphenationLibHyphencpp">trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfTinyLRUCacheh">trunk/Source/WTF/wtf/TinyLRUCache.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformtextAtomicStringKeyedMRUCacheh">trunk/Source/WebCore/platform/text/AtomicStringKeyedMRUCache.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (195355 => 195356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-01-20 17:16:34 UTC (rev 195355)
+++ trunk/Source/WTF/ChangeLog        2016-01-20 17:59:02 UTC (rev 195356)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-01-20  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        Refactor AtomicStringKeyedMRUCache to be a generic LRU cache
+        https://bugs.webkit.org/show_bug.cgi?id=153109
+
+        Reviewed by Darin Adler.
+
+        Refactor AtomicStringKeyedMRUCache, move it to WTF project and rename it
+        to be TinyLRUCache. Define another template and call it TinyLRUCachePolicy.
+        This one can be overridden for different keys and values. Its function is 
+        creating the cached values.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/TinyLRUCache.h: Added.
+        (WebCore::TinyLRUCachePolicy::isKeyNull):
+        (WebCore::TinyLRUCachePolicy::createValueForNullKey):
+        (WebCore::TinyLRUCachePolicy::createValueForKey):
+        (WebCore::TinyLRUCache::get):
+
</ins><span class="cx"> 2016-01-19  Saam barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WTF::Bag should be non-copyable
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (195355 => 195356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2016-01-20 17:16:34 UTC (rev 195355)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2016-01-20 17:59:02 UTC (rev 195356)
</span><span class="lines">@@ -96,6 +96,7 @@
</span><span class="cx">                 2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0F118115C85004DBA70 /* RunLoop.cpp */; };
</span><span class="cx">                 2CDED0F418115C85004DBA70 /* RunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CDED0F218115C85004DBA70 /* RunLoop.h */; };
</span><span class="cx">                 430B47891AAAAC1A001223DA /* StringCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 430B47871AAAAC1A001223DA /* StringCommon.h */; };
</span><ins>+                553071CA1C40427200384898 /* TinyLRUCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 553071C91C40427200384898 /* TinyLRUCache.h */; };
</ins><span class="cx">                 70A993FE1AD7151300FA615B /* SymbolRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 70A993FC1AD7151300FA615B /* SymbolRegistry.cpp */; };
</span><span class="cx">                 70A993FF1AD7151300FA615B /* SymbolRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 70A993FD1AD7151300FA615B /* SymbolRegistry.h */; };
</span><span class="cx">                 70ECA60D1B02426800449739 /* AtomicStringImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 70ECA60A1B02426800449739 /* AtomicStringImpl.cpp */; };
</span><span class="lines">@@ -402,6 +403,7 @@
</span><span class="cx">                 2CDED0F118115C85004DBA70 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 2CDED0F218115C85004DBA70 /* RunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoop.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 430B47871AAAAC1A001223DA /* StringCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringCommon.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                553071C91C40427200384898 /* TinyLRUCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TinyLRUCache.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 5D247B6214689B8600E78B76 /* libWTF.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWTF.a; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">                 5D247B6E14689C4700E78B76 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5D247B7014689C4700E78B76 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -928,6 +930,7 @@
</span><span class="cx">                                 A8A47336151A825B004123FF /* ThreadingPthreads.cpp */,
</span><span class="cx">                                 A8A4733E151A825B004123FF /* ThreadSafeRefCounted.h */,
</span><span class="cx">                                 A8A4733F151A825B004123FF /* ThreadSpecific.h */,
</span><ins>+                                553071C91C40427200384898 /* TinyLRUCache.h */,
</ins><span class="cx">                                 0FED67B51B22D4D80066CE15 /* TinyPtrSet.h */,
</span><span class="cx">                                 149EF16216BBFE0D000A4331 /* TriState.h */,
</span><span class="cx">                                 83FBA93119DF459700F30ADB /* TypeCasts.h */,
</span><span class="lines">@@ -1230,6 +1233,7 @@
</span><span class="cx">                                 A8A47416151A825B004123FF /* RandomNumberSeed.h in Headers */,
</span><span class="cx">                                 0F87105A16643F190090B0AD /* RawPointer.h in Headers */,
</span><span class="cx">                                 A8A47417151A825B004123FF /* RedBlackTree.h in Headers */,
</span><ins>+                                553071CA1C40427200384898 /* TinyLRUCache.h in Headers */,
</ins><span class="cx">                                 26299B6E17A9E5B800ADEBE5 /* Ref.h in Headers */,
</span><span class="cx">                                 A8A47418151A825B004123FF /* RefCounted.h in Headers */,
</span><span class="cx">                                 A8A47419151A825B004123FF /* RefCountedArray.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfTinyLRUCachehfromrev195355trunkSourceWebCoreplatformtextAtomicStringKeyedMRUCacheh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/TinyLRUCache.h (from rev 195355, trunk/Source/WebCore/platform/text/AtomicStringKeyedMRUCache.h) (0 => 195356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/TinyLRUCache.h                                (rev 0)
+++ trunk/Source/WTF/wtf/TinyLRUCache.h        2016-01-20 17:59:02 UTC (rev 195356)
</span><span class="lines">@@ -0,0 +1,81 @@
</span><ins>+/*
+ * Copyright (C) 2010, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TinyLRUCache_h
+#define TinyLRUCache_h
+
+#include &lt;wtf/NeverDestroyed.h&gt;
+#include &lt;wtf/Vector.h&gt;
+
+namespace WebCore {
+
+template&lt;typename KeyType, typename ValueType&gt;
+struct TinyLRUCachePolicy {
+    static bool isKeyNull(const KeyType&amp;) { return false; }
+    static ValueType createValueForNullKey() { return { }; }
+    static ValueType createValueForKey(const KeyType&amp;) { return { }; }
+};
+
+template&lt;typename KeyType, typename ValueType, size_t capacity = 4&gt;
+class TinyLRUCache {
+public:
+    const ValueType&amp; get(const KeyType&amp; key)
+    {
+        if (TinyLRUCachePolicy&lt;KeyType, ValueType&gt;::isKeyNull(key)) {
+            static NeverDestroyed&lt;ValueType&gt; valueForNull = TinyLRUCachePolicy&lt;KeyType, ValueType&gt;::createValueForNullKey();
+            return valueForNull;
+        }
+
+        for (size_t i = 0; i &lt; m_cache.size(); ++i) {
+            if (m_cache[i].first != key)
+                continue;
+
+            if (i == m_cache.size() - 1)
+                return m_cache[i].second;
+
+            // If the entry is not the last one, move it to the end of the cache.
+            Entry entry = WTFMove(m_cache[i]);
+            m_cache.remove(i);
+            m_cache.append(WTFMove(entry));
+            return m_cache[m_cache.size() - 1].second;
+        }
+
+        // m_cache[0] is the LRU entry, so remove it.
+        if (m_cache.size() == capacity)
+            m_cache.remove(0);
+
+        m_cache.append(std::make_pair(key, TinyLRUCachePolicy&lt;KeyType, ValueType&gt;::createValueForKey(key)));
+        return m_cache.last().second;
+    }
+
+private:
+    typedef std::pair&lt;KeyType, ValueType&gt; Entry;
+    typedef Vector&lt;Entry, capacity&gt; Cache;
+    Cache m_cache;
+};
+
+}
+
+#endif // TinyLRUCache_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (195355 => 195356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-20 17:16:34 UTC (rev 195355)
+++ trunk/Source/WebCore/ChangeLog        2016-01-20 17:59:02 UTC (rev 195356)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-01-20  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        Refactor AtomicStringKeyedMRUCache to be a generic LRU cache
+        https://bugs.webkit.org/show_bug.cgi?id=153109
+
+        Reviewed by Darin Adler.
+
+        Replace the template specialization of AtomicStringKeyedMRUCache with
+        template derived from TinyLRUCachePolicy. Override the functions which
+        are needed for creating the values and the null value. Also replace the
+        static function which was returning a NeverDestroyed AtomicStringKeyedMRUCache
+        with a singleton function 'cache' inside the derived template.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/text/AtomicStringKeyedMRUCache.h: Removed.
+        * platform/text/cf/HyphenationCF.cpp:
+        (WebCore::canHyphenate):
+        (WebCore::lastHyphenLocation):
+        (WebCore::AtomicStringKeyedMRUCache&lt;RetainPtr&lt;CFLocaleRef&gt;&gt;::createValueForNullKey): Deleted.
+        (WebCore::AtomicStringKeyedMRUCache&lt;RetainPtr&lt;CFLocaleRef&gt;&gt;::createValueForKey): Deleted.
+        (WebCore::cfLocaleCache): Deleted.
+        * platform/text/hyphen/HyphenationLibHyphen.cpp:
+        (WebCore::countLeadingSpaces):
+        (WebCore::lastHyphenLocation):
+        (WebCore::AtomicStringKeyedMRUCache&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;::createValueForNullKey): Deleted.
+        (WebCore::AtomicStringKeyedMRUCache&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;::createValueForKey): Deleted.
+        (WebCore::hyphenDictionaryCache): Deleted.
+
</ins><span class="cx"> 2016-01-20  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Drop support for obsolete Node.isSupported()
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (195355 => 195356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-01-20 17:16:34 UTC (rev 195355)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-01-20 17:59:02 UTC (rev 195356)
</span><span class="lines">@@ -1425,7 +1425,6 @@
</span><span class="cx">                 37C236101097EE7700EF9F72 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C2360E1097EE7700EF9F72 /* ComplexTextController.cpp */; };
</span><span class="cx">                 37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */; };
</span><span class="cx">                 37C238221098C84200EF9F72 /* ComplexTextControllerCoreText.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.mm */; };
</span><del>-                37C61F0112095C87007A3C67 /* AtomicStringKeyedMRUCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C61F0012095C87007A3C67 /* AtomicStringKeyedMRUCache.h */; };
</del><span class="cx">                 37D456FD1A9A50D8003330A1 /* LocalizableStrings.pm in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 37D456FB1A9A50B6003330A1 /* LocalizableStrings.pm */; };
</span><span class="cx">                 37DDCD9413844FD50008B793 /* MIMEHeader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37DDCD9213844FD50008B793 /* MIMEHeader.cpp */; };
</span><span class="cx">                 37DDCD9513844FD50008B793 /* MIMEHeader.h in Headers */ = {isa = PBXBuildFile; fileRef = 37DDCD9313844FD50008B793 /* MIMEHeader.h */; };
</span><span class="lines">@@ -8820,7 +8819,6 @@
</span><span class="cx">                 37C2360E1097EE7700EF9F72 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComplexTextController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ComplexTextControllerCoreText.mm; sourceTree = &quot;&lt;group&gt;&quot;; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
</span><del>-                37C61F0012095C87007A3C67 /* AtomicStringKeyedMRUCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AtomicStringKeyedMRUCache.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 37D456FB1A9A50B6003330A1 /* LocalizableStrings.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; path = LocalizableStrings.pm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 37DDCD9213844FD50008B793 /* MIMEHeader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MIMEHeader.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 37DDCD9313844FD50008B793 /* MIMEHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIMEHeader.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -21778,7 +21776,6 @@
</span><span class="cx">                                 7C74D43018823A4200E5ED57 /* icu */,
</span><span class="cx">                                 A516E8B2136E04C00076C3C0 /* ios */,
</span><span class="cx">                                 B2C3D9F90D006C1D00EF6F26 /* mac */,
</span><del>-                                37C61F0012095C87007A3C67 /* AtomicStringKeyedMRUCache.h */,
</del><span class="cx">                                 B2C3D9F20D006C1D00EF6F26 /* BidiContext.cpp */,
</span><span class="cx">                                 B2C3D9F30D006C1D00EF6F26 /* BidiContext.h */,
</span><span class="cx">                                 B2C3D9F40D006C1D00EF6F26 /* BidiResolver.h */,
</span><span class="lines">@@ -24650,7 +24647,6 @@
</span><span class="cx">                                 FD5686CA13AC180200B69C68 /* AsyncAudioDecoder.h in Headers */,
</span><span class="cx">                                 E1CDE9221501916900862CC5 /* AsyncFileStream.h in Headers */,
</span><span class="cx">                                 0FFD4D6118651FA300512F6E /* AsyncScrollingCoordinator.h in Headers */,
</span><del>-                                37C61F0112095C87007A3C67 /* AtomicStringKeyedMRUCache.h in Headers */,
</del><span class="cx">                                 A8C4A80D09D563270003AC8D /* Attr.h in Headers */,
</span><span class="cx">                                 A8C4A80B09D563270003AC8D /* Attribute.h in Headers */,
</span><span class="cx">                                 46233EEE1BA0F187000EBEBB /* AttributeDOMTokenList.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextAtomicStringKeyedMRUCacheh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/platform/text/AtomicStringKeyedMRUCache.h (195355 => 195356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/AtomicStringKeyedMRUCache.h        2016-01-20 17:16:34 UTC (rev 195355)
+++ trunk/Source/WebCore/platform/text/AtomicStringKeyedMRUCache.h        2016-01-20 17:59:02 UTC (rev 195356)
</span><span class="lines">@@ -1,74 +0,0 @@
</span><del>-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef AtomicStringKeyedMRUCache_h
-#define AtomicStringKeyedMRUCache_h
-
-#include &lt;wtf/NeverDestroyed.h&gt;
-#include &lt;wtf/text/AtomicString.h&gt;
-
-namespace WebCore {
-
-template&lt;typename T, size_t capacity = 4&gt;
-class AtomicStringKeyedMRUCache {
-public:
-    T get(const AtomicString&amp; key)
-    {
-        if (key.isNull()) {
-            static NeverDestroyed&lt;T&gt; valueForNull(createValueForNullKey());
-            return valueForNull;
-        }
-
-        for (size_t i = 0; i &lt; m_cache.size(); ++i) {
-            if (m_cache[i].first == key) {
-                size_t foundIndex = i;
-                if (foundIndex + 1 &lt; m_cache.size()) {
-                    Entry entry = m_cache[foundIndex];
-                    m_cache.remove(foundIndex);
-                    foundIndex = m_cache.size();
-                    m_cache.append(entry);
-                }
-                return m_cache[foundIndex].second;
-            }
-        }
-        if (m_cache.size() == capacity)
-            m_cache.remove(0);
-
-        m_cache.append(std::make_pair(key, createValueForKey(key)));
-        return m_cache.last().second;
-    }
-
-private:
-    T createValueForNullKey();
-    T createValueForKey(const AtomicString&amp;);
-
-    typedef std::pair&lt;AtomicString, T&gt; Entry;
-    typedef Vector&lt;Entry, capacity&gt; Cache;
-    Cache m_cache;
-};
-
-}
-
-#endif // AtomicStringKeyedMRUCache_h
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformtextcfHyphenationCFcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/cf/HyphenationCF.cpp (195355 => 195356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/cf/HyphenationCF.cpp        2016-01-20 17:16:34 UTC (rev 195355)
+++ trunk/Source/WebCore/platform/text/cf/HyphenationCF.cpp        2016-01-20 17:59:02 UTC (rev 195356)
</span><span class="lines">@@ -26,47 +26,54 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;Hyphenation.h&quot;
</span><span class="cx"> 
</span><del>-#include &quot;AtomicStringKeyedMRUCache.h&quot;
</del><span class="cx"> #include &quot;Language.h&quot;
</span><span class="cx"> #include &quot;TextBreakIteratorInternalICU.h&quot;
</span><span class="cx"> #include &lt;wtf/ListHashSet.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><ins>+#include &lt;wtf/TinyLRUCache.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/StringView.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt;
</span><del>-RetainPtr&lt;CFLocaleRef&gt; AtomicStringKeyedMRUCache&lt;RetainPtr&lt;CFLocaleRef&gt;&gt;::createValueForNullKey()
</del><ins>+class TinyLRUCachePolicy&lt;AtomicString, RetainPtr&lt;CFLocaleRef&gt;&gt;
</ins><span class="cx"> {
</span><del>-    // CF hyphenation functions use locale (regional formats) language, which doesn't necessarily match primary UI language,
-    // so we can't use default locale here. See &lt;rdar://problem/14897664&gt;.
-    RetainPtr&lt;CFLocaleRef&gt; locale = adoptCF(CFLocaleCreate(kCFAllocatorDefault, defaultLanguage().createCFString().get()));
</del><ins>+public:
+    static TinyLRUCache&lt;AtomicString, RetainPtr&lt;CFLocaleRef&gt;&gt;&amp; cache()
+    {
+        static NeverDestroyed&lt;TinyLRUCache&lt;AtomicString, RetainPtr&lt;CFLocaleRef&gt;&gt;&gt; cache;
+        return cache;
+    }
</ins><span class="cx"> 
</span><del>-    return CFStringIsHyphenationAvailableForLocale(locale.get()) ? locale : 0;
-}
</del><ins>+    static bool isKeyNull(const AtomicString&amp; localeIdentifier)
+    {
+        return localeIdentifier.isNull();
+    }
</ins><span class="cx"> 
</span><del>-template&lt;&gt;
-RetainPtr&lt;CFLocaleRef&gt; AtomicStringKeyedMRUCache&lt;RetainPtr&lt;CFLocaleRef&gt;&gt;::createValueForKey(const AtomicString&amp; localeIdentifier)
-{
-    RetainPtr&lt;CFLocaleRef&gt; locale = adoptCF(CFLocaleCreate(kCFAllocatorDefault, localeIdentifier.string().createCFString().get()));
</del><ins>+    static RetainPtr&lt;CFLocaleRef&gt; createValueForNullKey()
+    {
+        // CF hyphenation functions use locale (regional formats) language, which doesn't necessarily match primary UI language,
+        // so we can't use default locale here. See &lt;rdar://problem/14897664&gt;.
+        RetainPtr&lt;CFLocaleRef&gt; locale = adoptCF(CFLocaleCreate(kCFAllocatorDefault, defaultLanguage().createCFString().get()));
+        return CFStringIsHyphenationAvailableForLocale(locale.get()) ? locale : nullptr;
+    }
</ins><span class="cx"> 
</span><del>-    return CFStringIsHyphenationAvailableForLocale(locale.get()) ? locale : 0;
-}
</del><ins>+    static RetainPtr&lt;CFLocaleRef&gt; createValueForKey(const AtomicString&amp; localeIdentifier)
+    {
+        RetainPtr&lt;CFLocaleRef&gt; locale = adoptCF(CFLocaleCreate(kCFAllocatorDefault, localeIdentifier.string().createCFString().get()));
</ins><span class="cx"> 
</span><del>-static AtomicStringKeyedMRUCache&lt;RetainPtr&lt;CFLocaleRef&gt;&gt;&amp; cfLocaleCache()
-{
-    static NeverDestroyed&lt;AtomicStringKeyedMRUCache&lt;RetainPtr&lt;CFLocaleRef&gt;&gt;&gt; cache;
-    return cache;
-}
</del><ins>+        return CFStringIsHyphenationAvailableForLocale(locale.get()) ? locale : nullptr;
+    }
+};
</ins><span class="cx"> 
</span><span class="cx"> bool canHyphenate(const AtomicString&amp; localeIdentifier)
</span><span class="cx"> {
</span><del>-    return cfLocaleCache().get(localeIdentifier);
</del><ins>+    return TinyLRUCachePolicy&lt;AtomicString, RetainPtr&lt;CFLocaleRef&gt;&gt;::cache().get(localeIdentifier);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> size_t lastHyphenLocation(StringView text, size_t beforeIndex, const AtomicString&amp; localeIdentifier)
</span><span class="cx"> {
</span><del>-    RetainPtr&lt;CFLocaleRef&gt; locale = cfLocaleCache().get(localeIdentifier);
</del><ins>+    RetainPtr&lt;CFLocaleRef&gt; locale = TinyLRUCachePolicy&lt;AtomicString, RetainPtr&lt;CFLocaleRef&gt;&gt;::cache().get(localeIdentifier);
</ins><span class="cx">     ASSERT(locale);
</span><span class="cx"> 
</span><span class="cx">     CFOptionFlags searchAcrossWordBoundaries = 1;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtexthyphenHyphenationLibHyphencpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp (195355 => 195356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp        2016-01-20 17:16:34 UTC (rev 195355)
+++ trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp        2016-01-20 17:59:02 UTC (rev 195356)
</span><span class="lines">@@ -29,11 +29,11 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(LIBHYPHEN)
</span><span class="cx"> 
</span><del>-#include &quot;AtomicStringKeyedMRUCache.h&quot;
</del><span class="cx"> #include &quot;FileSystem.h&quot;
</span><span class="cx"> #include &lt;hyphen.h&gt;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><ins>+#include &lt;wtf/TinyLRUCache.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/AtomicStringHash.h&gt;
</span><span class="cx"> #include &lt;wtf/text/CString.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringView.h&gt;
</span><span class="lines">@@ -167,23 +167,31 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> template&lt;&gt;
</span><del>-RefPtr&lt;HyphenationDictionary&gt; AtomicStringKeyedMRUCache&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;::createValueForNullKey()
</del><ins>+class TinyLRUCachePolicy&lt;AtomicString, RefPtr&lt;HyphenationDictionary&gt;&gt;
</ins><span class="cx"> {
</span><del>-    return HyphenationDictionary::createNull();
-}
</del><ins>+public:
+    static TinyLRUCache&lt;AtomicString, RefPtr&lt;HyphenationDictionary&gt;&gt;&amp; cache()
+    {
+        static NeverDestroyed&lt;TinyLRUCache&lt;AtomicString, RefPtr&lt;HyphenationDictionary&gt;&gt;&gt; cache;
+        return cache;
+    }
</ins><span class="cx"> 
</span><del>-template&lt;&gt;
-RefPtr&lt;HyphenationDictionary&gt; AtomicStringKeyedMRUCache&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;::createValueForKey(const AtomicString&amp; dictionaryPath)
-{
-    return HyphenationDictionary::create(fileSystemRepresentation(dictionaryPath.string()));
-}
</del><ins>+    static bool isKeyNull(const AtomicString&amp; localeIdentifier)
+    {
+        return localeIdentifier.isNull();
+    }
</ins><span class="cx"> 
</span><del>-static AtomicStringKeyedMRUCache&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;&amp; hyphenDictionaryCache()
-{
-    static NeverDestroyed&lt;AtomicStringKeyedMRUCache&lt;RefPtr&lt;HyphenationDictionary&gt;&gt;&gt; cache;
-    return cache;
-}
</del><ins>+    static RefPtr&lt;HyphenationDictionary&gt; createValueForNullKey()
+    {
+        return HyphenationDictionary::createNull();
+    }
</ins><span class="cx"> 
</span><ins>+    static RefPtr&lt;HyphenationDictionary&gt; createValueForKey(const AtomicString&amp; dictionaryPath)
+    {
+        return HyphenationDictionary::create(fileSystemRepresentation(dictionaryPath.string()));
+    }
+};
+
</ins><span class="cx"> static void countLeadingSpaces(const CString&amp; utf8String, int32_t&amp; pointerOffset, int32_t&amp; characterOffset)
</span><span class="cx"> {
</span><span class="cx">     pointerOffset = 0;
</span><span class="lines">@@ -225,7 +233,7 @@
</span><span class="cx">     String lowercaseLocaleIdentifier = AtomicString(localeIdentifier.string().convertToASCIILowercase());
</span><span class="cx">     ASSERT(availableLocales().contains(lowercaseLocaleIdentifier));
</span><span class="cx">     for (const auto&amp; dictionaryPath : availableLocales().get(lowercaseLocaleIdentifier)) {
</span><del>-        RefPtr&lt;HyphenationDictionary&gt; dictionary = hyphenDictionaryCache().get(AtomicString(dictionaryPath));
</del><ins>+        RefPtr&lt;HyphenationDictionary&gt; dictionary = TinyLRUCachePolicy&lt;AtomicString, RefPtr&lt;HyphenationDictionary&gt;&gt;::cache().get(AtomicString(dictionaryPath));
</ins><span class="cx"> 
</span><span class="cx">         char** replacements = nullptr;
</span><span class="cx">         int* positions = nullptr;
</span></span></pre>
</div>
</div>

</body>
</html>