[clang-scan-deps] Remove const from ModuleDeps loop to enable move.#161109
Conversation
This changes the iteration from const to non-const so that std::move results in a true move rather than a copy.
|
@llvm/pr-subscribers-clang-modules @llvm/pr-subscribers-clang Author: Naveen Seth Hanig (naveen-seth) ChangesThis changes the iteration from const to non-const so that std::move results in a true move rather than a copy. Full diff: https://github.com/llvm/llvm-project/pull/161109.diff 1 Files Affected:
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 0e2758d123edc..e41f4eb7999ae 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -420,7 +420,7 @@ class FullDeps {
std::vector<ModuleDeps *> NewMDs;
{
std::unique_lock<std::mutex> ul(Lock);
- for (const ModuleDeps &MD : Graph) {
+ for (ModuleDeps &MD : Graph) {
auto I = Modules.find({MD.ID, 0});
if (I != Modules.end()) {
I->first.InputIndex = std::min(I->first.InputIndex, InputIndex);
|
ChuanqiXu9
left a comment
There was a problem hiding this comment.
Why is this a standalone PR? I feel this can be within other PR. The PR itself doesn't do anything.
|
Ah I see, I've moved it to #155523 now (even though that is also NFC). Hope that’s fine anyway. |
|
This PR does do something, it change a copy to a move of a large data structure, which has (minor) perf/memory impact. This seems fine to me as a standalone PR, and doesn't really fit as a side change in any other existing PR. |
…lvm#161109) This changes the iteration from const to non-const so that std::move results in a true move rather than a copy.
This changes the iteration from const to non-const so that std::move results in a true move rather than a copy.