diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-12-23 12:41:29 -0800 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-13 20:50:00 -0800 |
commit | c224a834583ccbb3f8e8047d409ef3bf356abc01 (patch) | |
tree | ea4fc4a7c30db1881dbae3c3b45a7206d5a1c8d5 | |
parent | 260a856c2abcef49c7cb3bdcd999701db3e2af38 (diff) | |
download | llvm-c224a834583ccbb3f8e8047d409ef3bf356abc01.tar.gz |
ADT: Reduce code duplication in SmallVector::resize by using pop_back_n, NFC
-rw-r--r-- | llvm/include/llvm/ADT/SmallVector.h | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index ac445e556ba1..32c149c4993f 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -545,8 +545,7 @@ public: private: template <bool ForOverwrite> void resizeImpl(size_type N) { if (N < this->size()) { - this->destroy_range(this->begin()+N, this->end()); - this->set_size(N); + this->pop_back_n(this->size() - N); } else if (N > this->size()) { if (this->capacity() < N) this->grow(N); @@ -570,8 +569,7 @@ public: return; if (N < this->size()) { - this->destroy_range(this->begin()+N, this->end()); - this->set_size(N); + this->pop_back_n(this->size() - N); return; } |