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

Nick Kledzik kledzik at apple.com
Thu Nov 20 13:42:35 PST 2014


On Nov 20, 2014, at 1:27 PM, Rui Ueyama <ruiu at google.com> wrote:
> On Thu, Nov 20, 2014 at 1:19 PM, Nick Kledzik <kledzik at apple.com> wrote:
> 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,
> 
> This is really nit, but the standard style is not auto& foo but auto &foo.
Fixed in r222457

-Nick

> 
>          [offsetInSect](const SectionOffsetAndAtom &ao,
>                         uint64_t targetAddr) -> bool {
>            // Each atom has a start offset of its slice of the
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141120/f8f5135b/attachment.html>


More information about the llvm-commits mailing list