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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user