diff options
author | Nathan James <n.james93@hotmail.co.uk> | 2020-11-03 14:57:08 +0000 |
---|---|---|
committer | Nathan James <n.james93@hotmail.co.uk> | 2020-11-03 14:57:10 +0000 |
commit | 97e8da45f9459ce9334c2d387ada7d2cde9625f4 (patch) | |
tree | e6ae888c2659f152f61b5dc50a52495e3ee9c65e /llvm/unittests/ADT/SmallVectorTest.cpp | |
parent | e8d67ef2dc93af671a2123caaf302709ba6e15d5 (diff) | |
download | llvm-97e8da45f9459ce9334c2d387ada7d2cde9625f4.zip llvm-97e8da45f9459ce9334c2d387ada7d2cde9625f4.tar.gz llvm-97e8da45f9459ce9334c2d387ada7d2cde9625f4.tar.bz2 |
[ADT] Add SmallVector::pop_back_n
Adds a method called pop_back_n to SmallVector.
This is more readable and less error prone than the alternatives of using
```lang=c++
Vector.resize(Vector.size() - N);
Vector.erase(Vector.end() - N, Vector.end());
for (unsigned I = 0;I<N;++I) Vector.pop_back();
```
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D90576
Diffstat (limited to 'llvm/unittests/ADT/SmallVectorTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/SmallVectorTest.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp index dbe4048..162716a 100644 --- a/llvm/unittests/ADT/SmallVectorTest.cpp +++ b/llvm/unittests/ADT/SmallVectorTest.cpp @@ -261,8 +261,7 @@ TYPED_TEST(SmallVectorTest, PushPopTest) { this->assertValuesInOrder(this->theVector, 2u, 2, 1); // Pop remaining elements - this->theVector.pop_back(); - this->theVector.pop_back(); + this->theVector.pop_back_n(2); this->assertEmpty(this->theVector); // Check number of constructor calls. Should be 2 for each list element, |