Title: [155484] trunk/Source
Revision
155484
Author
[email protected]
Date
2013-09-10 15:36:23 -0700 (Tue, 10 Sep 2013)

Log Message

More WTF/Alignment.h removal
https://bugs.webkit.org/show_bug.cgi?id=121125

Reviewed by Andreas Kling.

Source/WebCore:

* platform/PODArena.h:

Source/WTF:

* wtf/Alignment.h:
* wtf/Vector.h:
(WTF::VectorBuffer::swap):
(WTF::VectorBuffer::inlineBuffer):
* wtf/text/ASCIIFastPath.h:
(WTF::isAlignedTo):
(WTF::isAlignedToMachineWord):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (155483 => 155484)


--- trunk/Source/WTF/ChangeLog	2013-09-10 22:31:48 UTC (rev 155483)
+++ trunk/Source/WTF/ChangeLog	2013-09-10 22:36:23 UTC (rev 155484)
@@ -1,3 +1,18 @@
+2013-09-10  Anders Carlsson  <[email protected]>
+
+        More WTF/Alignment.h removal
+        https://bugs.webkit.org/show_bug.cgi?id=121125
+
+        Reviewed by Andreas Kling.
+
+        * wtf/Alignment.h:
+        * wtf/Vector.h:
+        (WTF::VectorBuffer::swap):
+        (WTF::VectorBuffer::inlineBuffer):
+        * wtf/text/ASCIIFastPath.h:
+        (WTF::isAlignedTo):
+        (WTF::isAlignedToMachineWord):
+
 2013-09-10  Brent Fulgham  <[email protected]>
 
         Unreviewed build fix after r155476.

Modified: trunk/Source/WTF/wtf/Alignment.h (155483 => 155484)


--- trunk/Source/WTF/wtf/Alignment.h	2013-09-10 22:31:48 UTC (rev 155483)
+++ trunk/Source/WTF/wtf/Alignment.h	2013-09-10 22:36:23 UTC (rev 155484)
@@ -60,11 +60,6 @@
             std::swap(a.buffer[i], b.buffer[i]);
     }
 
-    template <uintptr_t mask>
-    inline bool isAlignedTo(const void* pointer)
-    {
-        return !(reinterpret_cast<uintptr_t>(pointer) & mask);
-    }
 }
 
 #endif // WTF_Alignment_h

Modified: trunk/Source/WTF/wtf/Vector.h (155483 => 155484)


--- trunk/Source/WTF/wtf/Vector.h	2013-09-10 22:31:48 UTC (rev 155483)
+++ trunk/Source/WTF/wtf/Vector.h	2013-09-10 22:36:23 UTC (rev 155484)
@@ -21,7 +21,10 @@
 #ifndef WTF_Vector_h
 #define WTF_Vector_h
 
-#include <wtf/Alignment.h>
+#include <limits>
+#include <string.h>
+#include <type_traits>
+#include <utility>
 #include <wtf/CheckedArithmetic.h>
 #include <wtf/FastMalloc.h>
 #include <wtf/MallocPtr.h>
@@ -30,9 +33,6 @@
 #include <wtf/StdLibExtras.h>
 #include <wtf/ValueCheck.h>
 #include <wtf/VectorTraits.h>
-#include <limits>
-#include <string.h>
-#include <utility>
 
 namespace WTF {
 
@@ -455,20 +455,20 @@
         Base::reallocateBuffer(newCapacity);
     }
 
-    void swap(VectorBuffer<T, inlineCapacity>& other)
+    void swap(VectorBuffer& other)
     {
         if (buffer() == inlineBuffer() && other.buffer() == other.inlineBuffer()) {
-            WTF::swap(m_inlineBuffer, other.m_inlineBuffer);
+            std::swap_ranges(m_inlineBuffer, m_inlineBuffer + inlineCapacity, other.m_inlineBuffer);
             std::swap(m_capacity, other.m_capacity);
         } else if (buffer() == inlineBuffer()) {
             m_buffer = other.m_buffer;
             other.m_buffer = other.inlineBuffer();
-            WTF::swap(m_inlineBuffer, other.m_inlineBuffer);
+            std::swap_ranges(m_inlineBuffer, m_inlineBuffer + inlineCapacity, other.m_inlineBuffer);
             std::swap(m_capacity, other.m_capacity);
         } else if (other.buffer() == other.inlineBuffer()) {
             other.m_buffer = m_buffer;
             m_buffer = inlineBuffer();
-            WTF::swap(m_inlineBuffer, other.m_inlineBuffer);
+            std::swap_ranges(m_inlineBuffer, m_inlineBuffer + inlineCapacity, other.m_inlineBuffer);
             std::swap(m_capacity, other.m_capacity);
         } else {
             std::swap(m_buffer, other.m_buffer);
@@ -501,11 +501,10 @@
     using Base::m_buffer;
     using Base::m_capacity;
 
-    static const size_t m_inlineBufferSize = inlineCapacity * sizeof(T);
-    T* inlineBuffer() { return reinterpret_cast_ptr<T*>(m_inlineBuffer.buffer); }
-    const T* inlineBuffer() const { return reinterpret_cast_ptr<const T*>(m_inlineBuffer.buffer); }
+    T* inlineBuffer() { return reinterpret_cast_ptr<T*>(m_inlineBuffer); }
+    const T* inlineBuffer() const { return reinterpret_cast_ptr<const T*>(m_inlineBuffer); }
 
-    AlignedBuffer<m_inlineBufferSize, WTF_ALIGN_OF(T)> m_inlineBuffer;
+    typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type m_inlineBuffer[inlineCapacity];
 };
 
 struct UnsafeVectorOverflow {

Modified: trunk/Source/WTF/wtf/text/ASCIIFastPath.h (155483 => 155484)


--- trunk/Source/WTF/wtf/text/ASCIIFastPath.h	2013-09-10 22:31:48 UTC (rev 155483)
+++ trunk/Source/WTF/wtf/text/ASCIIFastPath.h	2013-09-10 22:36:23 UTC (rev 155484)
@@ -32,6 +32,12 @@
 
 namespace WTF {
 
+template <uintptr_t mask>
+inline bool isAlignedTo(const void* pointer)
+{
+    return !(reinterpret_cast<uintptr_t>(pointer) & mask);
+}
+
 // Assuming that a pointer is the size of a "machine word", then
 // uintptr_t is an integer type that is also a machine word.
 typedef uintptr_t MachineWord;
@@ -39,7 +45,7 @@
 
 inline bool isAlignedToMachineWord(const void* pointer)
 {
-    return !(reinterpret_cast<uintptr_t>(pointer) & machineWordAlignmentMask);
+    return isAlignedTo<machineWordAlignmentMask>(pointer);
 }
 
 template<typename T> inline T* alignToMachineWord(T* pointer)

Modified: trunk/Source/WebCore/ChangeLog (155483 => 155484)


--- trunk/Source/WebCore/ChangeLog	2013-09-10 22:31:48 UTC (rev 155483)
+++ trunk/Source/WebCore/ChangeLog	2013-09-10 22:36:23 UTC (rev 155484)
@@ -1,3 +1,12 @@
+2013-09-10  Anders Carlsson  <[email protected]>
+
+        More WTF/Alignment.h removal
+        https://bugs.webkit.org/show_bug.cgi?id=121125
+
+        Reviewed by Andreas Kling.
+
+        * platform/PODArena.h:
+
 2013-09-10  Eric Carlson  <[email protected]>
 
         Make MediaStream objects ScriptWrappable

Modified: trunk/Source/WebCore/platform/PODArena.h (155483 => 155484)


--- trunk/Source/WebCore/platform/PODArena.h	2013-09-10 22:31:48 UTC (rev 155483)
+++ trunk/Source/WebCore/platform/PODArena.h	2013-09-10 22:36:23 UTC (rev 155484)
@@ -27,6 +27,7 @@
 #define PODArena_h
 
 #include <stdint.h>
+#include <wtf/Alignment.h>
 #include <wtf/Assertions.h>
 #include <wtf/FastMalloc.h>
 #include <wtf/Noncopyable.h>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to