Skip to content

[flang] Change argument to const reference #95048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Conversation

klausler
Copy link
Contributor

cppcheck recommends that a std::map being passed by value be changed to a const reference.

Fixes #94932.

cppcheck recommends that a std::map being passed by value be
changed to a const reference.

Fixes llvm#94932.
@klausler klausler requested a review from dcb314 June 10, 2024 21:25
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Jun 10, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 10, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

cppcheck recommends that a std::map being passed by value be changed to a const reference.

Fixes #94932.


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

1 Files Affected:

  • (modified) flang/lib/Semantics/scope.cpp (+1-1)
diff --git a/flang/lib/Semantics/scope.cpp b/flang/lib/Semantics/scope.cpp
index a860040f7378c..89128e4a5049b 100644
--- a/flang/lib/Semantics/scope.cpp
+++ b/flang/lib/Semantics/scope.cpp
@@ -56,7 +56,7 @@ Scope &Scope::MakeScope(Kind kind, Symbol *symbol) {
 
 template <typename T>
 static std::vector<common::Reference<T>> GetSortedSymbols(
-    std::map<SourceName, MutableSymbolRef> symbols) {
+    const std::map<SourceName, MutableSymbolRef> &symbols) {
   std::vector<common::Reference<T>> result;
   result.reserve(symbols.size());
   for (auto &pair : symbols) {

Copy link

@dcb314 dcb314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@klausler klausler merged commit 9d9a85e into llvm:main Jun 12, 2024
10 checks passed
@klausler klausler deleted the bug94932 branch June 12, 2024 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flang/lib/Semantics/scope.cpp:59: Suggest avoid pointless copy of a map
3 participants