[clang-tools-extra] 77c842f - [clang-apply-replacements] Avoid repeated hash lookups (NFC) (#111783)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 10 08:15:59 PDT 2024
Author: Kazu Hirata
Date: 2024-10-10T08:15:48-07:00
New Revision: 77c842f44cc06951975fd4a85761e0bc830d185a
URL: https://github.com/llvm/llvm-project/commit/77c842f44cc06951975fd4a85761e0bc830d185a
DIFF: https://github.com/llvm/llvm-project/commit/77c842f44cc06951975fd4a85761e0bc830d185a.diff
LOG: [clang-apply-replacements] Avoid repeated hash lookups (NFC) (#111783)
Added:
Modified:
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
index 9e0da82dfd3806..b895075e4f31cc 100644
--- a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -148,11 +148,8 @@ groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
if (auto Entry = SM.getFileManager().getOptionalFileRef(Path)) {
if (SourceTU) {
- auto &Replaces = DiagReplacements[*Entry];
- auto It = Replaces.find(R);
- if (It == Replaces.end())
- Replaces.emplace(R, SourceTU);
- else if (It->second != SourceTU)
+ auto [It, Inserted] = DiagReplacements[*Entry].try_emplace(R, SourceTU);
+ if (!Inserted && It->second != SourceTU)
// This replacement is a duplicate of one suggested by another TU.
return;
}
More information about the cfe-commits
mailing list