Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions llvm/include/llvm/ADT/MapVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ class MapVector {
}

ValueT &operator[](const KeyT &Key) {
std::pair<KeyT, typename MapType::mapped_type> Pair = std::make_pair(Key, 0);
std::pair<typename MapType::iterator, bool> Result = Map.insert(Pair);
std::pair<typename MapType::iterator, bool> Result = Map.try_emplace(Key);
auto &I = Result.first->second;
if (Result.second) {
Vector.push_back(std::make_pair(Key, ValueT()));
Expand All @@ -119,7 +118,7 @@ class MapVector {

template <typename... Ts>
std::pair<iterator, bool> try_emplace(const KeyT &Key, Ts &&...Args) {
auto [It, Inserted] = Map.insert(std::make_pair(Key, 0));
auto [It, Inserted] = Map.try_emplace(Key);
if (Inserted) {
It->second = Vector.size();
Vector.emplace_back(std::piecewise_construct, std::forward_as_tuple(Key),
Expand All @@ -130,7 +129,7 @@ class MapVector {
}
template <typename... Ts>
std::pair<iterator, bool> try_emplace(KeyT &&Key, Ts &&...Args) {
auto [It, Inserted] = Map.insert(std::make_pair(Key, 0));
auto [It, Inserted] = Map.try_emplace(Key);
if (Inserted) {
It->second = Vector.size();
Vector.emplace_back(std::piecewise_construct,
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3881,7 +3881,7 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
if (!TypeUnitsUnderConstruction.empty() && AddrPool.hasBeenUsed())
return;

auto Ins = TypeSignatures.insert(std::make_pair(CTy, 0));
auto Ins = TypeSignatures.try_emplace(CTy);
if (!Ins.second) {
CU.addDIETypeSignature(RefDie, Ins.first->second);
return;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/MC/StringTableBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ size_t StringTableBuilder::add(CachedHashStringRef S) {
assert(S.size() > COFF::NameSize && "Short string in COFF string table!");

assert(!isFinalized());
auto P = StringIndexMap.insert(std::make_pair(S, 0));
auto P = StringIndexMap.try_emplace(S);
if (P.second) {
size_t Start = alignTo(Size, Alignment);
P.first->second = Start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void WebAssemblyFixIrreducibleControlFlow::makeSingleEntryLoop(
// add them as successors.
DenseMap<MachineBasicBlock *, unsigned> Indices;
for (auto *Entry : SortedEntries) {
auto Pair = Indices.insert(std::make_pair(Entry, 0));
auto Pair = Indices.try_emplace(Entry);
assert(Pair.second);

unsigned Index = MIB.getInstr()->getNumExplicitOperands() - 1;
Expand Down
Loading