From ddb992ad2f0541c5f69b738e82df8e490fdccaa0 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Mon, 22 Aug 2022 11:10:17 +0800 Subject: [PATCH] refactor: BuildMaxHeap --- datastructure/heap/maxheap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datastructure/heap/maxheap.go b/datastructure/heap/maxheap.go index 81e20c5..595d044 100644 --- a/datastructure/heap/maxheap.go +++ b/datastructure/heap/maxheap.go @@ -28,7 +28,7 @@ func NewMaxHeap[T any](comparator lancetconstraints.Comparator) *MaxHeap[T] { // BuildMaxHeap builds a MaxHeap instance with data and given comparator. func BuildMaxHeap[T any](data []T, comparator lancetconstraints.Comparator) *MaxHeap[T] { heap := &MaxHeap[T]{ - data: make([]T, 0), + data: make([]T, 0, len(data)), comparator: comparator, }