From 4ac6423b26170668f99ef2351091d5e1352b298a Mon Sep 17 00:00:00 2001 From: Connor Brewster Date: Sun, 17 Sep 2023 06:52:50 -0500 Subject: [PATCH] refactor(tvix/nar-bridge): Clean up directory popping loop This change got lost in the rebases in cl/9348. There's unnecessary `break`/`continues` that can be replaced by moving the conditional into the for loop condition. Change-Id: I559e21087630b05e483f768ab59f8067961a2eae Reviewed-on: https://cl.tvl.fyi/c/depot/+/9352 Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/nar-bridge/pkg/reader/reader.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tvix/nar-bridge/pkg/reader/reader.go b/tvix/nar-bridge/pkg/reader/reader.go index 9ff7b3fed..04e1e6f2a 100644 --- a/tvix/nar-bridge/pkg/reader/reader.go +++ b/tvix/nar-bridge/pkg/reader/reader.go @@ -195,16 +195,11 @@ func (r *Reader) Import( // We don't need to worry about the root node case, because we can only finish the root "/" // If we're at the end of the NAR reader (covered by the EOF check) - for { - // We never want to pop the root directory until we're completely done. - if len(stack) > 1 && !strings.HasPrefix(hdr.Path, stack[len(stack)-1].path+"/") { - err := popFromStack() - if err != nil { - return nil, fmt.Errorf("unable to pop from stack: %w", err) - } - continue + for len(stack) > 1 && !strings.HasPrefix(hdr.Path, stack[len(stack)-1].path+"/") { + err := popFromStack() + if err != nil { + return nil, fmt.Errorf("unable to pop from stack: %w", err) } - break } if hdr.Type == nar.TypeSymlink {