Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ImmutableTree): Update RenderShape to emit results in depth-first pre-order #960

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions immutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func (t *ImmutableTree) renderNode(node *Node, indent string, depth int, encoder
return []string{here}, nil
}

// recurse on inner node
here := fmt.Sprintf("%s%s", prefix, encoder(node.hash, depth, false))

rightNode, err := node.getRightNode(t)
Expand All @@ -108,12 +107,14 @@ func (t *ImmutableTree) renderNode(node *Node, indent string, depth int, encoder
return nil, err
}

result, err := t.renderNode(leftNode, indent, depth+1, encoder) // left
left, err := t.renderNode(leftNode, indent, depth+1, encoder)
if err != nil {
return nil, err
}

result = append(result, here)
// Return results in topological depth-first pre-order (parent before subtrees).
result := []string{here}
result = append(result, left...)
result = append(result, right...)
return result, nil
}
Expand Down
Loading