Skip to content

Commit

Permalink
[ELF] Simplify maybeCompress with lld::split. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Jan 30, 2022
1 parent bc1369f commit fcd8817
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lld/ELF/OutputSections.cpp
Expand Up @@ -12,6 +12,7 @@
#include "SymbolTable.h"
#include "SyntheticSections.h"
#include "Target.h"
#include "lld/Common/Arrays.h"
#include "lld/Common/Memory.h"
#include "lld/Common/Strings.h"
#include "llvm/BinaryFormat/Dwarf.h"
Expand Down Expand Up @@ -342,12 +343,8 @@ template <class ELFT> void OutputSection::maybeCompress() {

// Split input into 1-MiB shards.
constexpr size_t shardSize = 1 << 20;
const size_t numShards = (size + shardSize - 1) / shardSize;
auto shardsIn = std::make_unique<ArrayRef<uint8_t>[]>(numShards);
for (size_t i = 0, start = 0, end; start != size; ++i, start = end) {
end = std::min(start + shardSize, (size_t)size);
shardsIn[i] = makeArrayRef<uint8_t>(buf.get() + start, end - start);
}
auto shardsIn = split(makeArrayRef<uint8_t>(buf.get(), size), shardSize);
const size_t numShards = shardsIn.size();

// Compress shards and compute Alder-32 checksums. Use Z_SYNC_FLUSH for all
// shards but the last to flush the output to a byte boundary to be
Expand Down

0 comments on commit fcd8817

Please sign in to comment.