| Index: Source/platform/graphics/ListContainer.h
|
| diff --git a/Source/platform/graphics/ListContainer.h b/Source/platform/graphics/ListContainer.h
|
| index 5b317bb2c4523a18ef2021098ccabbd462f3d633..a63bffb698daf568c48aa1fe1cae414a7fefd40e 100644
|
| --- a/Source/platform/graphics/ListContainer.h
|
| +++ b/Source/platform/graphics/ListContainer.h
|
| @@ -149,6 +149,8 @@ protected:
|
| size_t size() const;
|
| bool empty() const;
|
|
|
| + size_t maxSizeForDerivedClass() const;
|
| +
|
| // Unlike the ListContainer method, this one does not invoke element destructors.
|
| void clear();
|
|
|
| @@ -262,6 +264,20 @@ public:
|
| return new (*at) DerivedElementType();
|
| }
|
|
|
| + // Appends a new item without copying. The original item will not be
|
| + // destructed and will be replaced with a new DerivedElementType. The
|
| + // DerivedElementType does not have to match the moved type as a full block
|
| + // of memory will be moved (up to maxSizeForDerivedClass()).
|
| + template <typename DerivedElementType>
|
| + void appendByMoving(DerivedElementType* item)
|
| + {
|
| + size_t maxSize = maxSizeForDerivedClass();
|
| + void* newItem = allocate(maxSize);
|
| + memcpy(newItem, static_cast<void*>(item), maxSize);
|
| + // Construct a new element in-place so it can be destructed safely.
|
| + new (item) DerivedElementType;
|
| + }
|
| +
|
| using ListContainerBase::size;
|
| using ListContainerBase::empty;
|
|
|
|
|