Commit 5a92061f authored by darin's avatar darin
Browse files

Reviewed by Alice.

        * wtf/Vector.h: Add an append that takes a pointer and length.
        Generalize the existing Vector append to work on vectors with
        any value for inlineCapacity. Change the append algorithm so
        it doesn't check capacity each time through the loop.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16533 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 68b1fa53
2006-09-22 Darin Adler <darin@apple.com>
Reviewed by Alice.
* wtf/Vector.h: Add an append that takes a pointer and length.
Generalize the existing Vector append to work on vectors with
any value for inlineCapacity. Change the append algorithm so
it doesn't check capacity each time through the loop.
2006-09-22 Steve Falkenburg <sfalken@apple.com>
 
Fix release build.
......
......@@ -384,9 +384,12 @@ namespace WTF {
void clear() { resize(0); }
template<typename U> void append(const U*, size_t);
template<typename U> void append(const U&);
template<typename U> void append(const Vector<U>&);
template<typename U, size_t c> void append(const Vector<U, c>&);
template<typename U> void insert(size_t position, const U&);
void remove(size_t position);
void removeLast()
......@@ -538,10 +541,22 @@ namespace WTF {
m_impl.deallocateBuffer(oldBuffer);
}
// templatizing these is better than just letting the conversion happen implicitly,
// Templatizing these is better than just letting the conversion happen implicitly,
// because for instance it allows a PassRefPtr to be appended to a RefPtr vector
// without refcount thrash.
template<typename T, size_t inlineCapacity> template<typename U>
void Vector<T, inlineCapacity>::append(const U* data, size_t dataSize)
{
size_t newSize = m_size + dataSize;
if (newSize > capacity())
data = expandCapacity(newSize, data);
T* dest = end();
for (size_t i = 0; i < dataSize; ++i)
new (&dest[i]) T(data[i]);
m_size = newSize;
}
template<typename T, size_t inlineCapacity> template<typename U>
inline void Vector<T, inlineCapacity>::append(const U& val)
{
......@@ -552,13 +567,10 @@ namespace WTF {
++m_size;
}
template<typename T, size_t inlineCapacity> template<typename U>
inline void Vector<T, inlineCapacity>::append(const Vector<U>& val)
template<typename T, size_t inlineCapacity> template<typename U, size_t c>
inline void Vector<T, inlineCapacity>::append(const Vector<U, c>& val)
{
if (size() + val.size() >= capacity())
expandCapacity(size() + val.size());
for (unsigned i = 0; i < val.size(); i++)
append(val[i]);
append(val.begin(), val.size());
}
template<typename T, size_t inlineCapacity> template<typename U>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment