diff options
author | Devang Patel <dpatel@apple.com> | 2009-10-26 17:09:00 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-10-26 17:09:00 +0000 |
commit | 5a1033a8edaa8f15b4b22d036b3145f5b7c47425 (patch) | |
tree | 6ce87e05307931d3839ee7008dd8eccbf1a2d279 /lib/VMCore | |
parent | 06d1f6ce94d480b878ebfc2a8b18d8448f7a7e60 (diff) | |
download | external_llvm-5a1033a8edaa8f15b4b22d036b3145f5b7c47425.zip external_llvm-5a1033a8edaa8f15b4b22d036b3145f5b7c47425.tar.gz external_llvm-5a1033a8edaa8f15b4b22d036b3145f5b7c47425.tar.bz2 |
Do not use expensive sort().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85130 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Metadata.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index ad9653f..4fadfed 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -344,20 +344,22 @@ getMDs(const Instruction *Inst, SmallVectorImpl<MDPairTy> &MDs) const { MDStoreTy::iterator I = MetadataStore.find(Inst); if (I == MetadataStore.end()) return; + MDs.resize(I->second.size()); for (MDMapTy::iterator MI = I->second.begin(), ME = I->second.end(); MI != ME; ++MI) - MDs.push_back(std::make_pair(MI->first, MI->second)); - std::sort(MDs.begin(), MDs.end()); + // MD kinds are numbered from 1. + MDs[MI->first - 1] = std::make_pair(MI->first, MI->second); } /// getHandlerNames - Populate client supplied smallvector using custome /// metadata name and ID. void MetadataContextImpl:: getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef> >&Names) const { + Names.resize(MDHandlerNames.size()); for (StringMap<unsigned>::const_iterator I = MDHandlerNames.begin(), E = MDHandlerNames.end(); I != E; ++I) - Names.push_back(std::make_pair(I->second, I->first())); - std::sort(Names.begin(), Names.end()); + // MD Handlers are numbered from 1. + Names[I->second - 1] = std::make_pair(I->second, I->first()); } /// ValueIsCloned - This handler is used to update metadata store |