package lattice import "sync" // neighborPool caches []uint32 slices to reduce GC pressure. // Slices are returned with length 0 and capacity 8. var neighborPool = sync.Pool{ New: func() any { return make([]uint32, 0, 8) }, } // getNeighborSlice returns a pre-allocated neighbor index slice from the pool. func getNeighborSlice() []uint32 { return neighborPool.Get().([]uint32)[:0] } // putNeighborSlice returns a neighbor index slice to the pool. func putNeighborSlice(s []uint32) { clear(s) neighborPool.Put(s[:0]) }