Title: [143687] trunk/Source
Revision
143687
Author
[email protected]
Date
2013-02-21 21:56:17 -0800 (Thu, 21 Feb 2013)

Log Message

Move fastlog2() to WTF/MathExtras.h so it can be used from multiple projects.

Rubberstamped by Geoff Garen.

Source/WebCore:

* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor): Remove the inline fastlog2 and use WTF::fastlog2.

Source/WTF:

* wtf/MathExtras.h:
(WTF::fastLog2):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (143686 => 143687)


--- trunk/Source/WTF/ChangeLog	2013-02-22 05:15:35 UTC (rev 143686)
+++ trunk/Source/WTF/ChangeLog	2013-02-22 05:56:17 UTC (rev 143687)
@@ -1,3 +1,12 @@
+2013-02-21  Brady Eidson  <[email protected]>
+
+        Move fastlog2() to WTF/MathExtras.h so it can be used from multiple projects.
+
+        Rubberstamped by Geoff Garen.
+
+        * wtf/MathExtras.h:
+        (WTF::fastLog2):
+
 2013-02-21  Andy Estes  <[email protected]>
 
         TriState.h should be a Project header

Modified: trunk/Source/WTF/wtf/MathExtras.h (143686 => 143687)


--- trunk/Source/WTF/wtf/MathExtras.h	2013-02-22 05:15:35 UTC (rev 143686)
+++ trunk/Source/WTF/wtf/MathExtras.h	2013-02-22 05:56:17 UTC (rev 143687)
@@ -431,6 +431,24 @@
     return v;
 }
 
+inline unsigned fastLog2(unsigned i)
+{
+    unsigned log2 = 0;
+    if (i & (i - 1))
+        log2 += 1;
+    if (i >> 16)
+        log2 += 16, i >>= 16;
+    if (i >> 8)
+        log2 += 8, i >>= 8;
+    if (i >> 4)
+        log2 += 4, i >>= 4;
+    if (i >> 2)
+        log2 += 2, i >>= 2;
+    if (i >> 1)
+        log2 += 1;
+    return log2;
+}
+
 } // namespace WTF
 
 #endif // #ifndef WTF_MathExtras_h

Modified: trunk/Source/WebCore/ChangeLog (143686 => 143687)


--- trunk/Source/WebCore/ChangeLog	2013-02-22 05:15:35 UTC (rev 143686)
+++ trunk/Source/WebCore/ChangeLog	2013-02-22 05:56:17 UTC (rev 143687)
@@ -1,3 +1,12 @@
+2013-02-21  Brady Eidson  <[email protected]>
+
+        Move fastlog2() to WTF/MathExtras.h so it can be used from multiple projects.
+
+        Rubberstamped by Geoff Garen.
+
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::lruListFor): Remove the inline fastlog2 and use WTF::fastlog2.
+
 2013-02-21  Dimitri Glazkov  <[email protected]>
 
         Split SelectorChecker's fast-checking logic into its own class.

Modified: trunk/Source/WebCore/loader/cache/MemoryCache.cpp (143686 => 143687)


--- trunk/Source/WebCore/loader/cache/MemoryCache.cpp	2013-02-22 05:15:35 UTC (rev 143686)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.cpp	2013-02-22 05:56:17 UTC (rev 143687)
@@ -45,6 +45,7 @@
 #include "WorkerThread.h"
 #include <stdio.h>
 #include <wtf/CurrentTime.h>
+#include <wtf/MathExtras.h>
 #include <wtf/MemoryInstrumentationHashMap.h>
 #include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/MemoryObjectInfo.h>
@@ -412,28 +413,10 @@
     resource->deleteIfPossible();
 }
 
-static inline unsigned fastLog2(unsigned i)
-{
-    unsigned log2 = 0;
-    if (i & (i - 1))
-        log2 += 1;
-    if (i >> 16)
-        log2 += 16, i >>= 16;
-    if (i >> 8)
-        log2 += 8, i >>= 8;
-    if (i >> 4)
-        log2 += 4, i >>= 4;
-    if (i >> 2)
-        log2 += 2, i >>= 2;
-    if (i >> 1)
-        log2 += 1;
-    return log2;
-}
-
 MemoryCache::LRUList* MemoryCache::lruListFor(CachedResource* resource)
 {
     unsigned accessCount = max(resource->accessCount(), 1U);
-    unsigned queueIndex = fastLog2(resource->size() / accessCount);
+    unsigned queueIndex = WTF::fastLog2(resource->size() / accessCount);
 #ifndef NDEBUG
     resource->m_lruIndex = queueIndex;
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to