forked from OSchip/llvm-project
[ELF] maybeCompress: replace vector<uint8_t> with unique_ptr<uint8_t[]>. NFC
And mention that it is zero-initialized. I do not notice a speed-up if changed to be uninitialized by forcing the zero filler in writeTo.
This commit is contained in:
parent
8597458278
commit
223f9dea3d
|
@ -337,9 +337,9 @@ template <class ELFT> void OutputSection::maybeCompress() {
|
|||
hdr->ch_size = size;
|
||||
hdr->ch_addralign = alignment;
|
||||
|
||||
// Write section contents to a temporary buffer and compress it.
|
||||
std::vector<uint8_t> buf(size);
|
||||
writeTo<ELFT>(buf.data());
|
||||
// Write uncompressed data to a temporary zero-initialized buffer.
|
||||
auto buf = std::make_unique<uint8_t[]>(size);
|
||||
writeTo<ELFT>(buf.get());
|
||||
// We chose 1 as the default compression level because it is the fastest. If
|
||||
// -O2 is given, we use level 6 to compress debug info more by ~15%. We found
|
||||
// that level 7 to 9 doesn't make much difference (~1% more compression) while
|
||||
|
@ -350,9 +350,9 @@ template <class ELFT> void OutputSection::maybeCompress() {
|
|||
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 != buf.size(); ++i, start = end) {
|
||||
end = std::min(start + shardSize, buf.size());
|
||||
shardsIn[i] = makeArrayRef<uint8_t>(buf.data() + start, end - start);
|
||||
for (size_t i = 0, start = 0, end; start != size; ++i, start = end) {
|
||||
end = std::min(start + shardSize, size);
|
||||
shardsIn[i] = makeArrayRef<uint8_t>(buf.get() + start, end - start);
|
||||
}
|
||||
|
||||
// Compress shards and compute Alder-32 checksums. Use Z_SYNC_FLUSH for all
|
||||
|
|
Loading…
Reference in New Issue