| Index: Source/core/css/RuleSet.cpp
|
| diff --git a/Source/core/css/RuleSet.cpp b/Source/core/css/RuleSet.cpp
|
| index d2444cf5bc3681920ea816a2708bc623165d771b..1970e0c0f2045dd922c8400a8b9b76ad2d26669e 100644
|
| --- a/Source/core/css/RuleSet.cpp
|
| +++ b/Source/core/css/RuleSet.cpp
|
| @@ -125,17 +125,14 @@ namespace {
|
| template<typename T>
|
| class TerminatedArrayBuilder {
|
| public:
|
| - explicit TerminatedArrayBuilder(PassOwnPtr<T> array)
|
| + explicit TerminatedArrayBuilder(PassOwnPtr<TerminatedArray<T> > array)
|
| : m_array(array)
|
| , m_count(0)
|
| , m_capacity(0)
|
| {
|
| if (!m_array)
|
| return;
|
| - for (T* item = m_array.get(); !item->isLastInArray(); ++item)
|
| - ++m_count;
|
| - ++m_count; // To count the last item itself.
|
| - m_capacity = m_count;
|
| + m_capacity = m_count = m_array->size();
|
| }
|
|
|
| void grow(size_t count)
|
| @@ -145,26 +142,26 @@ public:
|
| ASSERT(!m_count);
|
| ASSERT(!m_capacity);
|
| m_capacity = count;
|
| - m_array = adoptPtr(static_cast<T*>(fastMalloc(m_capacity * sizeof(T))));
|
| + m_array = TerminatedArray<T>::create(m_capacity);
|
| return;
|
| }
|
| m_capacity += count;
|
| - m_array = adoptPtr(static_cast<T*>(fastRealloc(m_array.leakPtr(), m_capacity * sizeof(T))));
|
| - m_array.get()[m_count - 1].setLastInArray(false);
|
| + m_array = m_array.leakPtr()->realloc(m_capacity);
|
| + m_array->at(m_count - 1).setLastInArray(false);
|
| }
|
|
|
| void append(const T& item)
|
| {
|
| RELEASE_ASSERT(m_count < m_capacity);
|
| ASSERT(!item.isLastInArray());
|
| - m_array.get()[m_count++] = item;
|
| + m_array->at(m_count++) = item;
|
| }
|
|
|
| - PassOwnPtr<T> release()
|
| + PassOwnPtr<TerminatedArray<T> > release()
|
| {
|
| RELEASE_ASSERT(m_count == m_capacity);
|
| if (m_array)
|
| - m_array.get()[m_count - 1].setLastInArray(true);
|
| + m_array->at(m_count - 1).setLastInArray(true);
|
| assertValid();
|
| return m_array.release();
|
| }
|
| @@ -175,14 +172,14 @@ private:
|
| {
|
| for (size_t i = 0; i < m_count; ++i) {
|
| bool isLastInArray = (i + 1 == m_count);
|
| - ASSERT(m_array.get()[i].isLastInArray() == isLastInArray);
|
| + ASSERT(m_array->at(i).isLastInArray() == isLastInArray);
|
| }
|
| }
|
| #else
|
| void assertValid() { }
|
| #endif
|
|
|
| - OwnPtr<T> m_array;
|
| + OwnPtr<TerminatedArray<T> > m_array;
|
| size_t m_count;
|
| size_t m_capacity;
|
| };
|
|
|