[lld] r222455 - [mach-o] use reference with "auto" to prevent copies

Nick Kledzik kledzik at apple.com
Thu Nov 20 13:19:58 PST 2014


Author: kledzik
Date: Thu Nov 20 15:19:58 2014
New Revision: 222455

URL: http://llvm.org/viewvc/llvm-project?rev=222455&view=rev
Log:
[mach-o] use reference with "auto" to prevent copies

Patch by Jean-Daniel Dupas

Modified:
    lld/trunk/lib/ReaderWriter/MachO/File.h

Modified: lld/trunk/lib/ReaderWriter/MachO/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/File.h?rev=222455&r1=222454&r2=222455&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/File.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/File.h Thu Nov 20 15:19:58 2014
@@ -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





More information about the llvm-commits mailing list