| Index: third_party/WebKit/Source/platform/heap/Handle.h
|
| diff --git a/third_party/WebKit/Source/platform/heap/Handle.h b/third_party/WebKit/Source/platform/heap/Handle.h
|
| index f8bb60f77477339e150fa20f0ccf977f1a182acd..7c713d3347d1b2ebc9f23508f4c3640ea2c064a9 100644
|
| --- a/third_party/WebKit/Source/platform/heap/Handle.h
|
| +++ b/third_party/WebKit/Source/platform/heap/Handle.h
|
| @@ -626,17 +626,39 @@ class PersistentHeapHashCountedSet : public PersistentHeapCollectionBase<HeapHas
|
| template<typename T, size_t inlineCapacity = 0>
|
| class PersistentHeapVector : public PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>> {
|
| public:
|
| - PersistentHeapVector() { }
|
| + PersistentHeapVector()
|
| + {
|
| + initializeUnusedSlots();
|
| + }
|
|
|
| explicit PersistentHeapVector(size_t size)
|
| : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(size)
|
| {
|
| + initializeUnusedSlots();
|
| + }
|
| +
|
| + PersistentHeapVector(const PersistentHeapVector& other)
|
| + : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(other)
|
| + {
|
| + initializeUnusedSlots();
|
| }
|
|
|
| template<size_t otherCapacity>
|
| PersistentHeapVector(const HeapVector<T, otherCapacity>& other)
|
| : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity>>(other)
|
| {
|
| + initializeUnusedSlots();
|
| + }
|
| +
|
| +private:
|
| + void initializeUnusedSlots()
|
| + {
|
| + // The PersistentHeapVector is allocated off heap along with its
|
| + // inline buffer (if any.) Maintain the invariant that unused
|
| + // slots are cleared for the off-heap inline buffer also.
|
| + size_t unusedSlots = this->capacity() - this->size();
|
| + if (unusedSlots)
|
| + this->clearUnusedSlots(this->end(), this->end() + unusedSlots);
|
| }
|
| };
|
|
|
|
|