From 499ffaf940a172990385f67f54d62c08d7ee3a0f Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Fri, 6 Feb 2026 20:55:04 +0300 Subject: [PATCH] NarIndexer: Implement skip This improves the performance of parseNarListing, which is used by commands like `nix nar ls` when the underlying source allows cheap seeks (like StringSource or FdSource that does lseek). For `nix nar ls` of a NAR for linux source tarball this cuts down the runtime almost in half (from 300ms -> 175ms). --- src/libutil/nar-listing.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libutil/nar-listing.cc b/src/libutil/nar-listing.cc index 1483c7a0c..2a9011d70 100644 --- a/src/libutil/nar-listing.cc +++ b/src/libutil/nar-listing.cc @@ -112,6 +112,12 @@ NarListing parseNarListing(Source & source) pos += n; return n; } + + void skip(size_t len) override + { + source.skip(len); + pos += len; + } }; NarIndexer indexer(source);