Changeset 16533 in webkit for trunk/JavaScriptCore/wtf
- Timestamp:
- Sep 22, 2006, 3:02:56 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/Vector.h
r15002 r16533 385 385 void clear() { resize(0); } 386 386 387 template<typename U> void append(const U*, size_t); 387 388 template<typename U> void append(const U&); 388 template<typename U> void append(const Vector<U>&); 389 template<typename U, size_t c> void append(const Vector<U, c>&); 390 389 391 template<typename U> void insert(size_t position, const U&); 392 390 393 void remove(size_t position); 391 394 … … 539 542 } 540 543 541 // templatizing these is better than just letting the conversion happen implicitly,544 // Templatizing these is better than just letting the conversion happen implicitly, 542 545 // because for instance it allows a PassRefPtr to be appended to a RefPtr vector 543 546 // without refcount thrash. 547 548 template<typename T, size_t inlineCapacity> template<typename U> 549 void Vector<T, inlineCapacity>::append(const U* data, size_t dataSize) 550 { 551 size_t newSize = m_size + dataSize; 552 if (newSize > capacity()) 553 data = expandCapacity(newSize, data); 554 T* dest = end(); 555 for (size_t i = 0; i < dataSize; ++i) 556 new (&dest[i]) T(data[i]); 557 m_size = newSize; 558 } 544 559 545 560 template<typename T, size_t inlineCapacity> template<typename U> … … 553 568 } 554 569 555 template<typename T, size_t inlineCapacity> template<typename U> 556 inline void Vector<T, inlineCapacity>::append(const Vector<U>& val) 557 { 558 if (size() + val.size() >= capacity()) 559 expandCapacity(size() + val.size()); 560 for (unsigned i = 0; i < val.size(); i++) 561 append(val[i]); 570 template<typename T, size_t inlineCapacity> template<typename U, size_t c> 571 inline void Vector<T, inlineCapacity>::append(const Vector<U, c>& val) 572 { 573 append(val.begin(), val.size()); 562 574 } 563 575
Note:
See TracChangeset
for help on using the changeset viewer.