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).
This commit is contained in:
Sergei Zimmerman
2026-02-06 20:55:04 +03:00
parent bbb4b009ec
commit 499ffaf940

View File

@@ -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);