Bug 729403 (part 1, take 2) - Add Vector::sizeOf{In,Ex}cludingThis(). r=luke.

--HG--
extra : rebase_source : d745c1b1b9ca30c6836c31b03ded4dcab22a2565
This commit is contained in:
Nicholas Nethercote 2012-02-26 20:18:13 -08:00
parent a60da3f47e
commit d6aeabe8ce

View File

@ -499,6 +499,17 @@ class Vector : private AllocPolicy
* shifting existing elements from |t + 1| onward one position lower.
*/
void erase(T *t);
/*
* Measure the size of the Vector's heap-allocated storage.
*/
size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const;
/*
* Like sizeOfExcludingThis, but also measures the size of the Vector
* object (which must be heap-allocated) itself.
*/
size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const;
};
/* This does the re-entrancy check plus several other sanity checks. */
@ -996,6 +1007,20 @@ Vector<T,N,AP>::replaceRawBuffer(T *p, size_t length)
#endif
}
template <class T, size_t N, class AP>
inline size_t
Vector<T,N,AP>::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const
{
return usingInlineStorage() ? 0 : mallocSizeOf(beginNoCheck());
}
template <class T, size_t N, class AP>
inline size_t
Vector<T,N,AP>::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const
{
return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf);
}
} /* namespace js */
#ifdef _MSC_VER