[ThinLTO] Avoid unnecesary hash lookups during metadata linking (NFC)

Replace sequences of count() followed by operator[] with either
find() or insert(), depending on the context.

llvm-svn: 258405
This commit is contained in:
Teresa Johnson
2016-01-21 16:46:40 +00:00
parent cb17d72170
commit 6f508afce1
2 changed files with 20 additions and 19 deletions

View File

@@ -3081,9 +3081,11 @@ void BitcodeReader::saveMetadataList(
if (!OnlyTempMD || (N && N->isTemporary())) {
// Will call this after materializing each function, in order to
// handle remapping of the function's instructions/metadata.
auto IterBool = MetadataToIDs.insert(std::make_pair(MD, ID));
// See if we already have an entry in that case.
if (OnlyTempMD && MetadataToIDs.count(MD)) {
assert(MetadataToIDs[MD] == ID && "Inconsistent metadata value id");
if (OnlyTempMD && !IterBool.second) {
assert(IterBool.first->second == ID &&
"Inconsistent metadata value id");
continue;
}
if (N && N->isTemporary())
@@ -3091,7 +3093,6 @@ void BitcodeReader::saveMetadataList(
// metadata while it is the key of a map. The flag will be set back
// to true when the saved metadata list is destroyed.
N->setCanReplace(false);
MetadataToIDs[MD] = ID;
}
}
}