[PATCH] D131046: [clang-tools-extra]Replace find/insert with try_emplace
ppenguin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 3 01:07:54 PDT 2022
prehistoric-penguin updated this revision to Diff 449572.
prehistoric-penguin added a comment.
Format change
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131046/new/
https://reviews.llvm.org/D131046
Files:
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
Index: clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===================================================================
--- clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -135,11 +135,9 @@
if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
if (SourceTU) {
auto &Replaces = DiagReplacements[*Entry];
- auto It = Replaces.find(R);
- if (It == Replaces.end())
- Replaces.emplace(R, SourceTU);
- else if (It->second != SourceTU)
- // This replacement is a duplicate of one suggested by another TU.
+ auto InsertPos = Replaces.try_emplace(R, SourceTU);
+ // This replacement is a duplicate of one suggested by another TU.
+ if (!InsertPos.second && InsertPos.first->second != SourceTU)
return;
}
GroupedReplacements[*Entry].push_back(R);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131046.449572.patch
Type: text/x-patch
Size: 999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220803/5b07a8de/attachment.bin>
More information about the cfe-commits
mailing list