const size_t nBits = wordsize * 8 - 1;
// Get offsets for all relative relocations and sort them.
- std::vector<uint64_t> offsets;
- for (const RelativeReloc &rel : relocs)
- offsets.push_back(rel.getOffset());
- llvm::sort(offsets);
+ std::unique_ptr<uint64_t[]> offsets(new uint64_t[relocs.size()]);
+ for (auto it : llvm::enumerate(relocs))
+ offsets[it.index()] = it.value().getOffset();
+ std::sort(offsets.get(), offsets.get() + relocs.size());
// For each leading relocation, find following ones that can be folded
// as a bitmap and fold them.
- for (size_t i = 0, e = offsets.size(); i < e;) {
+ for (size_t i = 0, e = relocs.size(); i != e;) {
// Add a leading relocation.
relrRelocs.push_back(Elf_Relr(offsets[i]));
uint64_t base = offsets[i] + wordsize;