From 6f508afce10b4347010b90e91fae94f9fe8bd9f3 Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Thu, 21 Jan 2016 16:46:40 +0000 Subject: [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 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 5a9711e..59e736c 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -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; } } } -- cgit v1.1