[mach-o] use reference with "auto" to prevent copies
authorNick Kledzik <kledzik@apple.com>
Thu, 20 Nov 2014 21:19:58 +0000 (21:19 +0000)
committerNick Kledzik <kledzik@apple.com>
Thu, 20 Nov 2014 21:19:58 +0000 (21:19 +0000)
Patch by Jean-Daniel Dupas

llvm-svn: 222455

lld/lib/ReaderWriter/MachO/File.h

index 7d0292d..e01c6a8 100644 (file)
@@ -118,13 +118,13 @@ public:
   MachODefinedAtom *findAtomCoveringAddress(const Section &section,
                                             uint64_t offsetInSect,
                                             uint32_t *foundOffsetAtom=nullptr) {
-    auto pos = _sectionAtoms.find(&section);
+    const auto& pos = _sectionAtoms.find(&section);
     if (pos == _sectionAtoms.end())
       return nullptr;
-    auto vec = pos->second;
+    const auto& vec = pos->second;
     assert(offsetInSect < section.content.size());
     // Vector of atoms for section are already sorted, so do binary search.
-    auto atomPos = std::lower_bound(vec.begin(), vec.end(), offsetInSect, 
+    const auto& atomPos = std::lower_bound(vec.begin(), vec.end(), offsetInSect,
         [offsetInSect](const SectionOffsetAndAtom &ao, 
                        uint64_t targetAddr) -> bool {
           // Each atom has a start offset of its slice of the