Do not use expensive sort().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85130 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2009-10-26 17:09:00 +00:00
parent 06d1f6ce94
commit 5a1033a8ed

View File

@ -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