From c6a4cd6e3a529e29c328b41ff9b0109b13188649 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 27 Feb 2025 16:08:50 +0100 Subject: [PATCH] libstore: don't use parseDump to discard nars this is a step towards using nar parser visitors only where we need nar parser visitors. the performance impact of this should be insignificant and perhaps slightly positive since we no longer allocate anything when discarding a file member. mostly it is a step towards a NARParseVisitor that has no default behavior; we have only three implementations total, and most of them don ot even *use* most of the default implementations. Change-Id: I3466d2a77500778eb152f56ebd441cf1be223dc6 --- lix/libstore/local-store.cc | 4 ++-- lix/libstore/store-api.cc | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lix/libstore/local-store.cc b/lix/libstore/local-store.cc index 265c74df6..9ea377dd0 100644 --- a/lix/libstore/local-store.cc +++ b/lix/libstore/local-store.cc @@ -1216,9 +1216,9 @@ try { bool narRead = false; Finally cleanup = [&]() { if (!narRead) { - NARParseVisitor sink; try { - parseDump(sink, source); + auto copy = copyNAR(source); + while (copy.next()) {} } catch (...) { ignoreExceptionExceptInterrupt(); } diff --git a/lix/libstore/store-api.cc b/lix/libstore/store-api.cc index 4be189b30..587827db3 100644 --- a/lix/libstore/store-api.cc +++ b/lix/libstore/store-api.cc @@ -461,14 +461,14 @@ try { information to narSink. */ TeeSource tapped { fileSource, narSink }; - NARParseVisitor blank; - auto & parseSink = method == FileIngestionMethod::Flat - ? fileSink - : blank; - - /* The information that flows from tapped (besides being replicated in - narSink), is now put in parseSink. */ - parseDump(parseSink, tapped); + // the information flows from tapped into narSink. we only check that the + // nar is correct, and during flat ingestion contains only a single file. + if (method == FileIngestionMethod::Flat) { + parseDump(fileSink, tapped); + } else { + auto copy = copyNAR(tapped); + while (copy.next()) {} + } /* We extract the result of the computation from the sink by calling finish. */