[all-commits] [llvm/llvm-project] 97e8da: [ADT] Add SmallVector::pop_back_n

Nathan James via All-commits all-commits at lists.llvm.org
Tue Nov 3 06:57:35 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 97e8da45f9459ce9334c2d387ada7d2cde9625f4
      https://github.com/llvm/llvm-project/commit/97e8da45f9459ce9334c2d387ada7d2cde9625f4
  Author: Nathan James <n.james93 at hotmail.co.uk>
  Date:   2020-11-03 (Tue, 03 Nov 2020)

  Changed paths:
    M llvm/include/llvm/ADT/SmallVector.h
    M llvm/unittests/ADT/SmallVectorTest.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list