[lld] r276715 - Replace std::find_if with plain for loop. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 25 17:21:15 PDT 2016
Author: ruiu
Date: Mon Jul 25 19:21:15 2016
New Revision: 276715
URL: http://llvm.org/viewvc/llvm-project?rev=276715&view=rev
Log:
Replace std::find_if with plain for loop. NFC.
Modified:
lld/trunk/ELF/LinkerScript.cpp
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=276715&r1=276714&r2=276715&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Jul 25 19:21:15 2016
@@ -351,16 +351,14 @@ ArrayRef<uint8_t> LinkerScript<ELFT>::ge
// were in the script. If a given name did not appear in the script,
// it returns INT_MAX, so that it will be laid out at end of file.
template <class ELFT> int LinkerScript<ELFT>::getSectionIndex(StringRef Name) {
- auto Begin = Opt.Commands.begin();
- auto End = Opt.Commands.end();
- auto I =
- std::find_if(Begin, End, [&](const std::unique_ptr<BaseCommand> &Base) {
- if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base.get()))
- if (Cmd->Name == Name)
- return true;
- return false;
- });
- return I == End ? INT_MAX : (I - Begin);
+ int I = 0;
+ for (std::unique_ptr<BaseCommand> &Base : Opt.Commands) {
+ if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base.get()))
+ if (Cmd->Name == Name)
+ return I;
+ ++I;
+ }
+ return INT_MAX;
}
// A compartor to sort output sections. Returns -1 or 1 if
More information about the llvm-commits
mailing list