[llvm] r358251 - MCDwarfLineTableheader::tryGetFile : replace a loop with llvm::find

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 11 21:55:10 PDT 2019


Author: maskray
Date: Thu Apr 11 21:55:10 2019
New Revision: 358251

URL: http://llvm.org/viewvc/llvm-project?rev=358251&view=rev
Log:
MCDwarfLineTableheader::tryGetFile : replace a loop with llvm::find

Note, `DirIndex++` below is incorrect for DWARF 5, but it can be fixed
later after the file index is fixed.

Modified:
    llvm/trunk/lib/MC/MCDwarf.cpp

Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=358251&r1=358250&r2=358251&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Apr 11 21:55:10 2019
@@ -606,11 +606,7 @@ MCDwarfLineTableHeader::tryGetFile(Strin
     // For FileNames with no directories a DirIndex of 0 is used.
     DirIndex = 0;
   } else {
-    DirIndex = 0;
-    for (unsigned End = MCDwarfDirs.size(); DirIndex < End; DirIndex++) {
-      if (Directory == MCDwarfDirs[DirIndex])
-        break;
-    }
+    DirIndex = llvm::find(MCDwarfDirs, Directory) - MCDwarfDirs.begin();
     if (DirIndex >= MCDwarfDirs.size())
       MCDwarfDirs.push_back(Directory);
     // The DirIndex is one based, as DirIndex of 0 is used for FileNames with




More information about the llvm-commits mailing list