From eae2b49fe3ddd13f85ae8da14676db42a7856aff Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 9 Dec 2018 01:46:01 +0000 Subject: SourceManager: insert(make_pair(..)) -> try_emplace. NFC llvm-svn: 348709 --- clang/lib/Basic/SourceManager.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'clang/lib/Basic/SourceManager.cpp') diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 6f35ecb5928..14c229c2a97 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/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. -- cgit v1.2.3