Skip to content

Conversation

@abhishek-kaushik22
Copy link
Contributor

Use const& in range-based for loop to avoid unnecessary copies

Use const& in range-based for loop to avoid unnecessary copies
@abhishek-kaushik22 abhishek-kaushik22 requested review from mingmingl-llvm and snehasish and removed request for mingmingl-llvm October 22, 2025 09:11
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Oct 22, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 22, 2025

@llvm/pr-subscribers-pgo

Author: Abhishek Kaushik (abhishek-kaushik22)

Changes

Use const& in range-based for loop to avoid unnecessary copies


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

1 Files Affected:

  • (modified) llvm/include/llvm/ProfileData/SampleProf.h (+1-1)
diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h
index 3dd34aba2d716..05f1b568b0643 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -1072,7 +1072,7 @@ class FunctionSamples {
     TypeCountMap &TypeCounts = getTypeSamplesAt(Loc);
     bool Overflowed = false;
 
-    for (const auto [Type, Count] : Other) {
+    for (const auto &[Type, Count] : Other) {
       FunctionId TypeId(Type);
       bool RowOverflow = false;
       TypeCounts[TypeId] = SaturatingMultiplyAdd(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PGO Profile Guided Optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants