Reducing memory allocation events

Former-commit-id: c94e79ba116464504580fc397270ead154063971
This commit is contained in:
Eric Coissac
2024-06-22 22:32:31 +02:00
parent e6b87ecd02
commit 93f9dcb95f
8 changed files with 98 additions and 46 deletions

View File

@ -1,15 +1,14 @@
package obialign
import "slices"
func _Backtracking(pathMatrix []int, lseqA, lseqB int, path *[]int) []int {
needed := (lseqA + lseqB) * 2
if needed > cap(*path) {
*path = make([]int, 0, needed)
}
*path = (*path)[:cap(*path)]
(*path) = (*path)[:0]
(*path) = slices.Grow((*path), needed)
p := cap(*path)
*path = (*path)[:p]
i := lseqA - 1
j := lseqB - 1