forked from OSchip/llvm-project
[sanitizer] Construct InternalMmapVector without memory allocation.
Construction of InternalMmapVector is often followed by a call to reserve(), which may result in immediate reallocation of the memory for the internal storage. This patch delays that allocation until it is really needed. Differential Revision: https://reviews.llvm.org/D71342
This commit is contained in:
parent
5279f96577
commit
a57adc7a0b
|
@ -552,7 +552,7 @@ bool operator!=(const InternalMmapVectorNoCtor<T> &lhs,
|
|||
template<typename T>
|
||||
class InternalMmapVector : public InternalMmapVectorNoCtor<T> {
|
||||
public:
|
||||
InternalMmapVector() { InternalMmapVectorNoCtor<T>::Initialize(1); }
|
||||
InternalMmapVector() { InternalMmapVectorNoCtor<T>::Initialize(0); }
|
||||
explicit InternalMmapVector(uptr cnt) {
|
||||
InternalMmapVectorNoCtor<T>::Initialize(cnt);
|
||||
this->resize(cnt);
|
||||
|
|
|
@ -131,7 +131,7 @@ TEST(SanitizerCommon, InternalMmapVector) {
|
|||
EXPECT_EQ((uptr)i, vector.size());
|
||||
}
|
||||
InternalMmapVector<uptr> empty_vector;
|
||||
CHECK_GT(empty_vector.capacity(), 0U);
|
||||
CHECK_EQ(empty_vector.capacity(), 0U);
|
||||
CHECK_EQ(0U, empty_vector.size());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue