[clang] [Tooling] Simplify code with StringMap::operator[] (NFC) (PR #113071)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 19 20:58:51 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/113071.diff
1 Files Affected:
- (modified) clang/lib/Tooling/Inclusions/HeaderIncludes.cpp (+3-4)
``````````diff
diff --git a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
index 0cb96097415ea8..01b3be700b9fad 100644
--- a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -335,10 +335,9 @@ HeaderIncludes::HeaderIncludes(StringRef FileName, StringRef Code,
// \p Offset: the start of the line following this include directive.
void HeaderIncludes::addExistingInclude(Include IncludeToAdd,
unsigned NextLineOffset) {
- auto Iter =
- ExistingIncludes.try_emplace(trimInclude(IncludeToAdd.Name)).first;
- Iter->second.push_back(std::move(IncludeToAdd));
- auto &CurInclude = Iter->second.back();
+ auto &Incs = ExistingIncludes[trimInclude(IncludeToAdd.Name)];
+ Incs.push_back(std::move(IncludeToAdd));
+ auto &CurInclude = Incs.back();
// The header name with quotes or angle brackets.
// Only record the offset of current #include if we can insert after it.
if (CurInclude.R.getOffset() <= MaxInsertOffset) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/113071
More information about the cfe-commits
mailing list