Skip to content

[llvm] Use *Map::try_emplace (NFC) #143321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/ObjCARC/BlotMapVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ template <class KeyT, class ValueT> class BlotMapVector {
const_iterator end() const { return Vector.end(); }

ValueT &operator[](const KeyT &Arg) {
std::pair<typename MapTy::iterator, bool> Pair =
Map.insert(std::make_pair(Arg, size_t(0)));
std::pair<typename MapTy::iterator, bool> Pair = Map.try_emplace(Arg);
if (Pair.second) {
size_t Num = Vector.size();
Pair.first->second = Num;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void ConstantHoistingPass::collectConstantCandidates(
ConstCandMapType::iterator Itr;
bool Inserted;
ConstPtrUnionType Cand = ConstInt;
std::tie(Itr, Inserted) = ConstCandMap.insert(std::make_pair(Cand, 0));
std::tie(Itr, Inserted) = ConstCandMap.try_emplace(Cand);
if (Inserted) {
ConstIntCandVec.push_back(ConstantCandidate(ConstInt));
Itr->second = ConstIntCandVec.size() - 1;
Expand Down Expand Up @@ -439,7 +439,7 @@ void ConstantHoistingPass::collectConstantCandidates(
ConstCandMapType::iterator Itr;
bool Inserted;
ConstPtrUnionType Cand = ConstExpr;
std::tie(Itr, Inserted) = ConstCandMap.insert(std::make_pair(Cand, 0));
std::tie(Itr, Inserted) = ConstCandMap.try_emplace(Cand);
if (Inserted) {
ExprCandVec.push_back(ConstantCandidate(
ConstantInt::get(Type::getInt32Ty(*Ctx), Offset.getLimitedValue()),
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2788,7 +2788,7 @@ std::pair<size_t, Immediate> LSRInstance::getUse(const SCEV *&Expr,
}

std::pair<UseMapTy::iterator, bool> P =
UseMap.insert(std::make_pair(LSRUse::SCEVUseKindPair(Expr, Kind), 0));
UseMap.try_emplace(LSRUse::SCEVUseKindPair(Expr, Kind));
if (!P.second) {
// A use already existed with this base.
size_t LUIdx = P.first->second;
Expand Down
Loading