1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-08 14:42:27 +08:00

Pre-allocate memory to reduce the number of allocations (#272)

This commit is contained in:
Yurun
2024-11-27 14:58:02 +08:00
committed by GitHub
parent 1eb793420e
commit 05b85a2131
12 changed files with 15 additions and 12 deletions

View File

@@ -27,7 +27,7 @@ func NewLinkedQueue[T any]() *LinkedQueue[T] {
// Data return slice of queue data
func (q *LinkedQueue[T]) Data() []T {
res := []T{}
res := make([]T, 0, q.length)
current := q.head
for current != nil {