]> granicus.if.org Git - llvm/commitdiff
MCDwarfLineTableheader::tryGetFile : replace a loop with llvm::find
authorFangrui Song <maskray@google.com>
Fri, 12 Apr 2019 04:55:10 +0000 (04:55 +0000)
committerFangrui Song <maskray@google.com>
Fri, 12 Apr 2019 04:55:10 +0000 (04:55 +0000)
Note, `DirIndex++` below is incorrect for DWARF 5, but it can be fixed
later after the file index is fixed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358251 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCDwarf.cpp

index a95d97b70d90f41033f3463accef8fae9e963026..262c520a06a3d6ddac6d1ccb4c4eb4d1c9cbe819 100644 (file)
@@ -606,11 +606,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory,
     // 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