1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

ADT: Reduce code duplication in SmallVector by reusing reserve, NFC

This commit is contained in:
Duncan P. N. Exon Smith 2020-12-23 12:45:17 -08:00
parent 1f680ae2d9
commit a94b40b819

View File

@ -547,8 +547,7 @@ private:
if (N < this->size()) {
this->pop_back_n(this->size() - N);
} else if (N > this->size()) {
if (this->capacity() < N)
this->grow(N);
this->reserve(N);
for (auto I = this->end(), E = this->begin() + N; I != E; ++I)
if (ForOverwrite)
new (&*I) T;
@ -628,8 +627,7 @@ public:
void assign(size_type NumElts, const T &Elt) {
this->assertSafeToReferenceAfterResize(&Elt, 0);
clear();
if (this->capacity() < NumElts)
this->grow(NumElts);
this->reserve(NumElts);
this->set_size(NumElts);
std::uninitialized_fill(this->begin(), this->end(), Elt);
}