Remove more uses of WTF::AlignedBuffer
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Sep 2013 21:18:53 +0000 (21:18 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Sep 2013 21:18:53 +0000 (21:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121119

Reviewed by Andreas Kling.

* wtf/HashTable.h:
* wtf/SizeLimits.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155474 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/HashTable.h
Source/WTF/wtf/SizeLimits.cpp

index 655ef0f..339636a 100644 (file)
@@ -1,5 +1,15 @@
 2013-09-10  Anders Carlsson  <andersca@apple.com>
 
+        Remove more uses of WTF::AlignedBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=121119
+
+        Reviewed by Andreas Kling.
+
+        * wtf/HashTable.h:
+        * wtf/SizeLimits.cpp:
+
+2013-09-10  Anders Carlsson  <andersca@apple.com>
+
         Clean up wtf/Noncopyable.h
         https://bugs.webkit.org/show_bug.cgi?id=121115
 
index 0218151..cce9818 100644 (file)
@@ -23,7 +23,8 @@
 #define WTF_HashTable_h
 
 #include <string.h>
-#include <wtf/Alignment.h>
+#include <type_traits>
+#include <utility>
 #include <wtf/Assertions.h>
 #include <wtf/FastMalloc.h>
 #include <wtf/HashTraits.h>
@@ -590,8 +591,8 @@ namespace WTF {
         if (!HashFunctions::safeToCompareToEmptyOrDeleted)
             return;
         ASSERT(!HashTranslator::equal(KeyTraits::emptyValue(), key));
-        AlignedBuffer<sizeof(ValueType), WTF_ALIGN_OF(ValueType)> deletedValueBuffer;
-        ValueType* deletedValuePtr = reinterpret_cast_ptr<ValueType*>(deletedValueBuffer.buffer);
+        typename std::aligned_storage<sizeof(ValueType), std::alignment_of<ValueType>::value>::type deletedValueBuffer;
+        ValueType* deletedValuePtr = reinterpret_cast_ptr<ValueType*>(&deletedValueBuffer);
         ValueType& deletedValue = *deletedValuePtr;
         Traits::constructDeletedValue(deletedValue);
         ASSERT(!HashTranslator::equal(Extractor::extract(deletedValue), key));
index ab2b100..f5820c9 100644 (file)
@@ -30,6 +30,8 @@
 
 #include "config.h"
 
+#include <type_traits>
+#include <utility>
 #include <wtf/Assertions.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
@@ -67,16 +69,16 @@ struct SameSizeAsVectorWithInlineCapacity<T, 0> {
 template<typename T, unsigned inlineCapacity>
 struct SameSizeAsVectorWithInlineCapacity {
     SameSizeAsVectorWithInlineCapacity<T, 0> baseCapacity;
-    AlignedBuffer<inlineCapacity * sizeof(T), WTF_ALIGN_OF(T)> inlineBuffer;
+    typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type inlineBuffer[inlineCapacity];
 };
 
-COMPILE_ASSERT(sizeof(OwnPtr<int>) == sizeof(int*), OwnPtr_should_stay_small);
-COMPILE_ASSERT(sizeof(PassRefPtr<RefCounted<int> >) == sizeof(int*), PassRefPtr_should_stay_small);
-COMPILE_ASSERT(sizeof(RefCounted<int>) == sizeof(SameSizeAsRefCounted), RefCounted_should_stay_small);
-COMPILE_ASSERT(sizeof(RefCountedCustomAllocated<int>) == sizeof(SameSizeAsRefCounted), RefCountedCustomAllocated_should_stay_small);
-COMPILE_ASSERT(sizeof(RefPtr<RefCounted<int> >) == sizeof(int*), RefPtr_should_stay_small);
-COMPILE_ASSERT(sizeof(Vector<int>) == sizeof(SameSizeAsVectorWithInlineCapacity<int>), Vector_should_stay_small);
-COMPILE_ASSERT(sizeof(Vector<int, 1>) == sizeof(SameSizeAsVectorWithInlineCapacity<int, 1>), Vector_should_stay_small);
-COMPILE_ASSERT(sizeof(Vector<int, 2>) == sizeof(SameSizeAsVectorWithInlineCapacity<int, 2>), Vector_should_stay_small);
-COMPILE_ASSERT(sizeof(Vector<int, 3>) == sizeof(SameSizeAsVectorWithInlineCapacity<int, 3>), Vector_should_stay_small);
+static_assert(sizeof(OwnPtr<int>) == sizeof(int*), "OwnPtr should stay small!");
+static_assert(sizeof(PassRefPtr<RefCounted<int> >) == sizeof(int*), "PassRefPtr should stay small!");
+static_assert(sizeof(RefCounted<int>) == sizeof(SameSizeAsRefCounted), "RefCounted should stay small!");
+static_assert(sizeof(RefCountedCustomAllocated<int>) == sizeof(SameSizeAsRefCounted), "RefCountedCustomAllocated should stay small!");
+static_assert(sizeof(RefPtr<RefCounted<int> >) == sizeof(int*), "RefPtr should stay small!");
+static_assert(sizeof(Vector<int>) == sizeof(SameSizeAsVectorWithInlineCapacity<int>), "Vector should stay small!");
+static_assert(sizeof(Vector<int, 1>) == sizeof(SameSizeAsVectorWithInlineCapacity<int, 1>), "Vector should stay small!");
+static_assert(sizeof(Vector<int, 2>) == sizeof(SameSizeAsVectorWithInlineCapacity<int, 2>), "Vector should stay small!");
+static_assert(sizeof(Vector<int, 3>) == sizeof(SameSizeAsVectorWithInlineCapacity<int, 3>), "Vector should stay small!");
 }