]> granicus.if.org Git - clang/commitdiff
SourceManager: insert(make_pair(..)) -> try_emplace. NFC
authorFangrui Song <maskray@google.com>
Sun, 9 Dec 2018 01:46:01 +0000 (01:46 +0000)
committerFangrui Song <maskray@google.com>
Sun, 9 Dec 2018 01:46:01 +0000 (01:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348709 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/SourceManager.cpp

index 6f35ecb592832e812eacc3bf586172917c773399..14c229c2a973cc08de6a76984a1d071fa1870cb5 100644 (file)
@@ -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<FileID, unsigned>;
-  using MapTy = llvm::DenseMap<FileID, DecompTy>;
-  std::pair<MapTy::iterator, bool>
-    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.