refactor(nix-compat/nar/reader): reuse prev_name allocation

We reuse the prev_name allocation for Entry, instead of allocating and
returning a separate Vec.

We encode the `prev_name: None` case as an empty vector, since we don't
allow empty names anyway, and the sorting is equivalent.

Change-Id: I975b37ff873805f5ff099bc82128706891052247
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11607
Reviewed-by: Brian Olsen <me@griff.name>
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
edef 2024-05-08 07:13:39 +00:00
parent 17a7dac94f
commit 31d73cd443
8 changed files with 73 additions and 50 deletions

View file

@ -147,7 +147,7 @@ fn ingest(node: nar::Node, name: Vec<u8>, avg_chunk_size: u32) -> Result<proto::
let mut symlinks = vec![];
while let Some(node) = reader.next()? {
match ingest(node.node, node.name, avg_chunk_size)? {
match ingest(node.node, node.name.to_owned(), avg_chunk_size)? {
proto::path::Node::Directory(node) => {
directories.push(node);
}