summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2020-12-23 12:41:29 -0800
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2021-01-13 20:50:00 -0800
commitc224a834583ccbb3f8e8047d409ef3bf356abc01 (patch)
treeea4fc4a7c30db1881dbae3c3b45a7206d5a1c8d5
parent260a856c2abcef49c7cb3bdcd999701db3e2af38 (diff)
downloadllvm-c224a834583ccbb3f8e8047d409ef3bf356abc01.tar.gz
ADT: Reduce code duplication in SmallVector::resize by using pop_back_n, NFC
-rw-r--r--llvm/include/llvm/ADT/SmallVector.h6
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;
}