mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 12:06:01 +01:00
Merge pull request #13577 from NixOS/mergify/bp/2.28-maintenance/pr-13175
libutil/tarfile: Create the scratch `std::vector` only once (backport #13175)
This commit is contained in:
commit
0d763f7ce2
1 changed files with 4 additions and 1 deletions
|
|
@ -182,6 +182,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;
|
||||
|
|
@ -216,7 +220,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)
|
||||
throw Error("cannot read file '%s' from tarball", path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue