summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Metadata.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-04-24 20:23:44 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-04-24 20:23:44 +0000
commit75ef0c09d0b5c3f9b6ee9e1dc1874b9d0001e8a4 (patch)
tree97d76ad433bd6df9fbc4a19db493c9151535b017 /llvm/lib/IR/Metadata.cpp
parenta211afa448c811c7e1b00e5edf712c15ddd09bcd (diff)
downloadbcm5719-llvm-75ef0c09d0b5c3f9b6ee9e1dc1874b9d0001e8a4.tar.gz
bcm5719-llvm-75ef0c09d0b5c3f9b6ee9e1dc1874b9d0001e8a4.zip
IR: Use remove_if for Instruction::dropUnknownMetadata()
Technically the operations are different -- the old logic moved items from the back into the opened-up slots, instead of the usual `remove_if()` logic of a slow and a fast iterator -- but unless a profile tells us otherwise I prefer the simpler logic here. Regardless, there shouldn't be an observable function change. llvm-svn: 235767
Diffstat (limited to 'llvm/lib/IR/Metadata.cpp')
-rw-r--r--llvm/lib/IR/Metadata.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 6e54fa918b3..752c4b276b7 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -1007,22 +1007,14 @@ void Instruction::dropUnknownMetadata(ArrayRef<unsigned> KnownIDs) {
}
auto &Info = InstructionMetadata[this];
- unsigned I;
- unsigned E;
- // Walk the array and drop any metadata we don't know.
- for (I = 0, E = Info.size(); I != E;) {
- if (KnownSet.count(Info[I].first)) {
- ++I;
- continue;
- }
-
- Info[I] = std::move(Info.back());
- Info.pop_back();
- --E;
- }
- assert(E == Info.size());
-
- if (E == 0) {
+ Info.erase(std::remove_if(
+ Info.begin(), Info.end(),
+ [&KnownSet](const std::pair<unsigned, TrackingMDNodeRef> &I) {
+ return !KnownSet.count(I.first);
+ }),
+ Info.end());
+
+ if (Info.empty()) {
// Drop our entry at the store.
InstructionMetadata.erase(this);
setHasMetadataHashEntry(false);
OpenPOWER on IntegriCloud