From a11abc02e26186b698bfe5ba6271f28e512c6cf6 Mon Sep 17 00:00:00 2001 From: edef Date: Sun, 19 Nov 2023 06:56:03 +0000 Subject: feat(nix-compat/nar/reader): provide passthrough buffered I/O Allow taking advantage of the buffer of the underlying reader to avoid unnecessary copies of file data. We can't easily implement the methods of BufRead directly, since we have some extra I/O to perform in the final consume() invocation. That could be resolved at the cost of additional bookkeeping, but this will suffice for now. Change-Id: I8100cf0abd79e7469670b8596bd989be5db44a91 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10089 Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/store/src/nar/import.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tvix/store/src/nar') diff --git a/tvix/store/src/nar/import.rs b/tvix/store/src/nar/import.rs index 000fc05663b2..e9065a670d21 100644 --- a/tvix/store/src/nar/import.rs +++ b/tvix/store/src/nar/import.rs @@ -135,13 +135,13 @@ fn process_file_reader( // write the blob. let mut blob_writer = { - let mut dest = SyncIoBridge::new(blob_writer); - io::copy(&mut file_reader, &mut dest)?; + let mut dst = SyncIoBridge::new(blob_writer); - dest.shutdown()?; + file_reader.copy(&mut dst)?; + dst.shutdown()?; - // return back the blob_reader - dest.into_inner() + // return back the blob_writer + dst.into_inner() }; // close the blob_writer, retrieve the digest. -- cgit 1.4.1