[llvm] [ProfileData] Use a range-based for loop (NFC) (PR #94856)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 8 07:20:36 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

While I am at it, this patch adds const to a couple of places.

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


1 Files Affected:

- (modified) llvm/lib/ProfileData/InstrProfReader.cpp (+4-4) 


``````````diff
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 7758363d9c952..27855bf92b871 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -145,11 +145,11 @@ readBinaryIdsInternal(const MemoryBuffer &DataBuffer,
 
 static void
 printBinaryIdsInternal(raw_ostream &OS,
-                       std::vector<llvm::object::BuildID> &BinaryIds) {
+                       const std::vector<llvm::object::BuildID> &BinaryIds) {
   OS << "Binary IDs: \n";
-  for (auto BI : BinaryIds) {
-    for (uint64_t I = 0; I < BI.size(); I++)
-      OS << format("%02x", BI[I]);
+  for (const auto &BI : BinaryIds) {
+    for (auto I : BI)
+      OS << format("%02x", I);
     OS << "\n";
   }
 }

``````````

</details>


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


More information about the llvm-commits mailing list