From ad4f140ad378c1bd97d4d3cf07ca88892abc2430 Mon Sep 17 00:00:00 2001 From: Hein Meling Date: Tue, 24 Dec 2024 22:27:52 +0100 Subject: [PATCH] refactor(tree): avoid allocation of empty slice of IDs --- internal/tree/treeconfig.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/tree/treeconfig.go b/internal/tree/treeconfig.go index d4594ab7..b458ff5c 100644 --- a/internal/tree/treeconfig.go +++ b/internal/tree/treeconfig.go @@ -116,17 +116,16 @@ func (t *Tree) NodeHeight() int { return t.heightOf(t.id) } -// PeersOf returns the peers of given ID, if any. +// PeersOf returns the sibling peers of given ID, if any. func (t *Tree) PeersOf(nodeID hotstuff.ID) []hotstuff.ID { - peers := make([]hotstuff.ID, 0) if t.IsRoot(nodeID) { - return peers + return nil } parent, ok := t.Parent() if !ok { - return peers + return nil } - return t.ChildrenOfNode(parent) + return t.ChildrenOf(parent) } // SubTree returns all the nodes of its subtree.