[clang-tools-extra] [clangd] Simplify code with *Map::operator[] (NFC) (PR #111939)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 10 20:41:40 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111939
None
>From aeebcbd92118161c1a75aefa369ba11f40f79ddd Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 10 Oct 2024 08:37:40 -0700
Subject: [PATCH] [clangd] Simplify code with *Map::operator[] (NFC)
---
clang-tools-extra/clangd/Headers.cpp | 4 ++--
clang-tools-extra/clangd/XRefs.cpp | 3 +--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/clang-tools-extra/clangd/Headers.cpp b/clang-tools-extra/clangd/Headers.cpp
index 75f8668e7bef06..b537417bd10568 100644
--- a/clang-tools-extra/clangd/Headers.cpp
+++ b/clang-tools-extra/clangd/Headers.cpp
@@ -75,8 +75,8 @@ class IncludeStructure::RecordHeaders : public PPCallbacks {
IDs.push_back(HID);
}
}
- Out->MainFileIncludesBySpelling.try_emplace(Inc.Written)
- .first->second.push_back(Out->MainFileIncludes.size() - 1);
+ Out->MainFileIncludesBySpelling[Inc.Written].push_back(
+ Out->MainFileIncludes.size() - 1);
}
// Record include graph (not just for main-file includes)
diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp
index f94cadeffaa298..b34aba603b5306 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -2282,8 +2282,7 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) {
elog("incomingCalls failed to convert location: {0}", Loc.takeError());
return;
}
- auto It = CallsIn.try_emplace(R.Container, std::vector<Range>{}).first;
- It->second.push_back(Loc->range);
+ CallsIn[R.Container].push_back(Loc->range);
ContainerLookup.IDs.insert(R.Container);
});
More information about the cfe-commits
mailing list