[lld] r193975 - [ELF] Simplify SectionTable::getSymbolTableIndex. No functionality change.

Rui Ueyama ruiu at google.com
Sun Nov 3 19:24:14 PST 2013


Author: ruiu
Date: Sun Nov  3 21:24:14 2013
New Revision: 193975

URL: http://llvm.org/viewvc/llvm-project?rev=193975&view=rev
Log:
[ELF] Simplify SectionTable::getSymbolTableIndex. No functionality change.

MSVC 2012 raises an error in the lambda passed to vector::find_if, while it
seems valid code. Rewrote without high-order functions.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h

Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=193975&r1=193974&r2=193975&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Sun Nov  3 21:24:14 2013
@@ -638,13 +638,10 @@ public:
   /// \brief Get the symbol table index for an Atom. If it's not in the symbol
   /// table, return STN_UNDEF.
   uint32_t getSymbolTableIndex(const Atom *a) const {
-    auto entry = std::find_if(_symbolTable.begin(), _symbolTable.end(),
-                           [=](const SymbolEntry &se) {
-      return se._atom == a;
-    });
-    if (entry == _symbolTable.end())
-      return STN_UNDEF;
-    return std::distance(_symbolTable.begin(), entry);
+    for (size_t i = 0, e = _symbolTable.size(); i < e; ++i)
+      if (_symbolTable[i]._atom == a)
+        return i;
+    return STN_UNDEF;
   }
 
   virtual void finalize() { finalize(true); }





More information about the llvm-commits mailing list