From f9d2d512c7476e60b6a3a7f626550580b79da613 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 18 May 2014 15:14:13 +0000 Subject: Options: Use erase_if to remove Args from the list. While there make getOption return a const reference so we don't have to put it on the stack when calling methods on it. No functionality change. llvm-svn: 209088 --- llvm/lib/Option/ArgList.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'llvm/lib/Option') diff --git a/llvm/lib/Option/ArgList.cpp b/llvm/lib/Option/ArgList.cpp index 1f16331e079..a5ab8d747d8 100644 --- a/llvm/lib/Option/ArgList.cpp +++ b/llvm/lib/Option/ArgList.cpp @@ -41,14 +41,9 @@ void ArgList::append(Arg *A) { } void ArgList::eraseArg(OptSpecifier Id) { - for (iterator it = begin(), ie = end(); it != ie; ) { - if ((*it)->getOption().matches(Id)) { - it = Args.erase(it); - ie = end(); - } else { - ++it; - } - } + Args.erase(std::remove_if(begin(), end(), + [=](Arg *A) { return A->getOption().matches(Id); }), + end()); } Arg *ArgList::getLastArgNoClaim(OptSpecifier Id) const { -- cgit v1.2.3