[PATCH] D90576: [ADT] Add SmallVector::pop_back_n
Nathan James via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 1 18:21:56 PST 2020
njames93 added a comment.
In D90576#2367400 <https://reviews.llvm.org/D90576#2367400>, @dblaikie wrote:
> More expressive in what way(s)?
`Vector.resize(Vector.size() - 2);` This takes a little longer to reason and its more error prone. If a typo or bad refactor caused the call to size to be on a different container which just happens to have a size method, that could easily go unnoticed
`Vector.pop_back_n(2)` is very easy to see what its doing and it removes the aforementioned risk.
> Could/should this use naming conventions from StringPiece? (there's various drop_n, etc)
I'm easy on the name, don't really know where pop_back_n came from to be honest. I considered what `ArrayRef` and `StringRef` use, `drop_back`, but that didn't sound quite as nice.
Overloading `pop_back` could work, but I don't know if anything would be gained from that.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90576/new/
https://reviews.llvm.org/D90576
More information about the llvm-commits
mailing list