aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-01-21 16:46:40 +0000
committerTeresa Johnson <tejohnson@google.com>2016-01-21 16:46:40 +0000
commit6f508afce10b4347010b90e91fae94f9fe8bd9f3 (patch)
tree6e3c695d6c22b651142f2838c393a81fbaab7788 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parentcb17d72170cb1bba19ec29ae62cf453aa2015389 (diff)
downloadllvm-6f508afce10b4347010b90e91fae94f9fe8bd9f3.zip
llvm-6f508afce10b4347010b90e91fae94f9fe8bd9f3.tar.gz
llvm-6f508afce10b4347010b90e91fae94f9fe8bd9f3.tar.bz2
[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
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp7
1 files changed, 4 insertions, 3 deletions
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;
}
}
}