mirror of
https://github.com/NixOS/nix
synced 2025-06-24 18:01:16 +02:00
Merge pull request #13175 from xokdvium/optimise-fetchtarball
libutil/tarfile: Create the scratch `std::vector` only once
This commit is contained in:
commit
f0f196cef0
1 changed files with 4 additions and 1 deletions
|
@ -178,6 +178,10 @@ time_t unpackTarfileToSink(TarArchive & archive, ExtendedFileSystemObjectSink &
|
|||
{
|
||||
time_t lastModified = 0;
|
||||
|
||||
/* Only allocate the buffer once. Use the heap because 131 KiB is a bit too
|
||||
much for the stack. */
|
||||
std::vector<unsigned char> buf(128 * 1024);
|
||||
|
||||
for (;;) {
|
||||
// FIXME: merge with extract_archive
|
||||
struct archive_entry * entry;
|
||||
|
@ -212,7 +216,6 @@ time_t unpackTarfileToSink(TarArchive & archive, ExtendedFileSystemObjectSink &
|
|||
crf.isExecutable();
|
||||
|
||||
while (true) {
|
||||
std::vector<unsigned char> buf(128 * 1024);
|
||||
auto n = archive_read_data(archive.archive, buf.data(), buf.size());
|
||||
if (n < 0)
|
||||
checkLibArchive(archive.archive, n, "cannot read file from tarball: %s");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue