mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-10 07:42:27 +08:00
Pre-allocate memory to reduce the number of allocations (#272)
This commit is contained in:
@@ -147,7 +147,7 @@ func printTreeNodes[T any](nodes []*datastructure.TreeNode[T], level, maxLevel i
|
||||
|
||||
printSpaces(firstSpaces)
|
||||
|
||||
newNodes := []*datastructure.TreeNode[T]{}
|
||||
newNodes := make([]*datastructure.TreeNode[T], 0, len(nodes)*2)
|
||||
for _, node := range nodes {
|
||||
if node != nil {
|
||||
fmt.Printf("%v", node.Value)
|
||||
|
||||
Reference in New Issue
Block a user