[llvm] Change `auto` to `const auto &` to avoid copying (PR #102122)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 6 04:09:30 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mc

Author: None (abhishek-kaushik22)

<details>
<summary>Changes</summary>

Change `auto` to `const auto &` to avoid copying in `MachObjectWriter::bindIndirectSymbols`

---
Full diff: https://github.com/llvm/llvm-project/pull/102122.diff


1 Files Affected:

- (modified) llvm/lib/MC/MachObjectWriter.cpp (+2-2) 


``````````diff
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 8596f457574a3..dce043d17a594 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -541,7 +541,7 @@ void MachObjectWriter::bindIndirectSymbols(MCAssembler &Asm) {
   }
 
   // Bind non-lazy symbol pointers first.
-  for (auto [IndirectIndex, ISD] : enumerate(IndirectSymbols)) {
+  for (const auto &[IndirectIndex, ISD] : enumerate(IndirectSymbols)) {
     const auto &Section = cast<MCSectionMachO>(*ISD.Section);
 
     if (Section.getType() != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
@@ -555,7 +555,7 @@ void MachObjectWriter::bindIndirectSymbols(MCAssembler &Asm) {
   }
 
   // Then lazy symbol pointers and symbol stubs.
-  for (auto [IndirectIndex, ISD] : enumerate(IndirectSymbols)) {
+  for (const auto &[IndirectIndex, ISD] : enumerate(IndirectSymbols)) {
     const auto &Section = cast<MCSectionMachO>(*ISD.Section);
 
     if (Section.getType() != MachO::S_LAZY_SYMBOL_POINTERS &&

``````````

</details>


https://github.com/llvm/llvm-project/pull/102122


More information about the llvm-commits mailing list