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 | 8ee697fb1b40b4b5c3b34176ae60add0a815c44d (patch) | |
tree | 079c5e6c267ab1e1f04f9d66c0b4b921d0cb3e22 /lib/Basic/SourceManager.cpp | |
parent | 14b0eac48e69f7bea5815c1614310497fdc49c30 (diff) | |
download | clang-8ee697fb1b40b4b5c3b34176ae60add0a815c44d.tar.gz |
Standardize on StringMap::insert, removing uses of StringMap::GetOrCreateValue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222306 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r-- | lib/Basic/SourceManager.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 6991783056..305dcd4396 100644 --- a/lib/Basic/SourceManager.cpp +++ b/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 |