Changeset 143044 in webkit
- Timestamp:
- Feb 15, 2013, 1:30:17 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r143043 r143044 1 2013-02-15 Andreas Kling <akling@apple.com> 2 3 ShareableElementData should use zero-length array for storage. 4 <http://webkit.org/b/109959> 5 6 Reviewed by Anders Carlsson. 7 8 Use a zero-length Attribute array instead of always casting from void* to an array. 9 It was done this way originally because I didn't know we could sidestep the MSVC 10 build error with some #pragma hackery. 11 12 * dom/DocumentSharedObjectPool.cpp: 13 (WebCore::DocumentSharedObjectPool::cachedShareableElementDataWithAttributes): 14 * dom/Element.cpp: 15 (WebCore::sizeForShareableElementDataWithAttributeCount): 16 (WebCore::ShareableElementData::ShareableElementData): 17 (WebCore::ShareableElementData::~ShareableElementData): 18 (WebCore::UniqueElementData::UniqueElementData): 19 * dom/Element.h: 20 (ShareableElementData): 21 (WebCore::ElementData::attributeItem): 22 1 23 2013-02-14 Ojan Vafai <ojan@chromium.org> 2 24 -
trunk/Source/WebCore/dom/DocumentSharedObjectPool.cpp
r142826 r143044 87 87 return elementData.release(); 88 88 89 cacheIterator->value = adoptPtr(new ShareableElementDataCacheEntry(ShareableElementDataCacheKey(elementData-> immutableAttributeArray(), elementData->length()), elementData));89 cacheIterator->value = adoptPtr(new ShareableElementDataCacheEntry(ShareableElementDataCacheKey(elementData->m_attributeArray, elementData->length()), elementData)); 90 90 91 91 return elementData.release(); -
trunk/Source/WebCore/dom/Element.cpp
r143014 r143044 2864 2864 static size_t sizeForShareableElementDataWithAttributeCount(unsigned count) 2865 2865 { 2866 return sizeof(ShareableElementData) - sizeof(void*)+ sizeof(Attribute) * count;2866 return sizeof(ShareableElementData) + sizeof(Attribute) * count; 2867 2867 } 2868 2868 … … 2882 2882 { 2883 2883 for (unsigned i = 0; i < m_arraySize; ++i) 2884 new (& reinterpret_cast<Attribute*>(&m_attributeArray)[i]) Attribute(attributes[i]);2884 new (&m_attributeArray[i]) Attribute(attributes[i]); 2885 2885 } 2886 2886 … … 2888 2888 { 2889 2889 for (unsigned i = 0; i < m_arraySize; ++i) 2890 (reinterpret_cast<Attribute*>(&m_attributeArray)[i]).~Attribute();2890 m_attributeArray[i].~Attribute(); 2891 2891 } 2892 2892 … … 2902 2902 2903 2903 for (unsigned i = 0; i < m_arraySize; ++i) 2904 new (& reinterpret_cast<Attribute*>(&m_attributeArray)[i]) Attribute(other.m_attributeVector.at(i));2904 new (&m_attributeArray[i]) Attribute(other.m_attributeVector.at(i)); 2905 2905 } 2906 2906 … … 2940 2940 m_attributeVector.reserveCapacity(other.length()); 2941 2941 for (unsigned i = 0; i < other.length(); ++i) 2942 m_attributeVector.uncheckedAppend(other. immutableAttributeArray()[i]);2942 m_attributeVector.uncheckedAppend(other.m_attributeArray[i]); 2943 2943 } 2944 2944 -
trunk/Source/WebCore/dom/Element.h
r143014 r143044 120 120 }; 121 121 122 #if COMPILER(MSVC) 123 #pragma warning(push) 124 #pragma warning(disable: 4200) // Disable "zero-sized array in struct/union" warning 125 #endif 126 122 127 class ShareableElementData : public ElementData { 123 128 public: 124 129 static PassRefPtr<ShareableElementData> createWithAttributes(const Vector<Attribute>&); 125 130 126 const Attribute* immutableAttributeArray() const { return reinterpret_cast<const Attribute*>(&m_attributeArray); }127 128 131 explicit ShareableElementData(const Vector<Attribute>&); 129 132 explicit ShareableElementData(const UniqueElementData&); 130 133 ~ShareableElementData(); 131 134 132 void* m_attributeArray;135 Attribute m_attributeArray[0]; 133 136 }; 137 138 #if COMPILER(MSVC) 139 #pragma warning(pop) 140 #endif 134 141 135 142 class UniqueElementData : public ElementData { … … 1035 1042 if (m_isUnique) 1036 1043 return &static_cast<const UniqueElementData*>(this)->m_attributeVector.at(index); 1037 return &static_cast<const ShareableElementData*>(this)-> immutableAttributeArray()[index];1044 return &static_cast<const ShareableElementData*>(this)->m_attributeArray[index]; 1038 1045 } 1039 1046
Note:
See TracChangeset
for help on using the changeset viewer.