diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-11-19 03:06:06 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-11-19 03:06:06 +0000 |
commit | 13156b689e67e2857769f96adad141203d844e16 (patch) | |
tree | dcb4058a1a9dd9a0466a5d6ee8eacefc8981358d /clang/lib/Basic/SourceManager.cpp | |
parent | 8e6cf9e5791083103ea711200b8315520c502adb (diff) | |
download | llvm-13156b689e67e2857769f96adad141203d844e16.zip llvm-13156b689e67e2857769f96adad141203d844e16.tar.gz llvm-13156b689e67e2857769f96adad141203d844e16.tar.bz2 |
Standardize on StringMap::insert, removing uses of StringMap::GetOrCreateValue.
llvm-svn: 222306
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 6991783..305dcd4 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -177,17 +177,11 @@ llvm::MemoryBuffer *ContentCache::getBuffer(DiagnosticsEngine &Diag, } unsigned LineTableInfo::getLineTableFilenameID(StringRef Name) { - // Look up the filename in the string table, returning the pre-existing value - // if it exists. - llvm::StringMapEntry<unsigned> &Entry = - FilenameIDs.GetOrCreateValue(Name, ~0U); - if (Entry.getValue() != ~0U) - return Entry.getValue(); - - // Otherwise, assign this the next available ID. - Entry.setValue(FilenamesByID.size()); - FilenamesByID.push_back(&Entry); - return FilenamesByID.size()-1; + auto IterBool = + FilenameIDs.insert(std::make_pair(Name, FilenamesByID.size())); + if (IterBool.second) + FilenamesByID.push_back(&*IterBool.first); + return IterBool.first->second; } /// AddLineNote - Add a line note to the line table that indicates that there |