From: Fangrui Song Date: Sun, 9 Dec 2018 01:46:01 +0000 (+0000) Subject: SourceManager: insert(make_pair(..)) -> try_emplace. NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a7d1b31c5066f9a5b1d9d4a2cabbd235da019372;p=clang SourceManager: insert(make_pair(..)) -> try_emplace. NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348709 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 6f35ecb592..14c229c2a9 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -195,8 +195,7 @@ llvm::MemoryBuffer *ContentCache::getBuffer(DiagnosticsEngine &Diag, } unsigned LineTableInfo::getLineTableFilenameID(StringRef Name) { - auto IterBool = - FilenameIDs.insert(std::make_pair(Name, FilenamesByID.size())); + auto IterBool = FilenameIDs.try_emplace(Name, FilenamesByID.size()); if (IterBool.second) FilenamesByID.push_back(&*IterBool.first); return IterBool.first->second; @@ -1965,9 +1964,7 @@ SourceManager::getDecomposedIncludedLoc(FileID FID) const { // Uses IncludedLocMap to retrieve/cache the decomposed loc. using DecompTy = std::pair; - using MapTy = llvm::DenseMap; - std::pair - InsertOp = IncludedLocMap.insert(std::make_pair(FID, DecompTy())); + auto InsertOp = IncludedLocMap.try_emplace(FID); DecompTy &DecompLoc = InsertOp.first->second; if (!InsertOp.second) return DecompLoc; // already in map.