minor optimization switching to wavefront pointers

This commit is contained in:
Arthur Lu 2024-11-08 21:51:17 +00:00
parent 1bbf38aaab
commit bd720f06fb
3 changed files with 9 additions and 9 deletions

View File

@ -101,13 +101,13 @@ type WavefrontComponent struct {
}
// NewWavefrontComponent: returns initialized WavefrontComponent
func NewWavefrontComponent(preallocateSize int) WavefrontComponent {
func NewWavefrontComponent(preallocateSize int) *WavefrontComponent {
// new wavefront component = {
// lo = [0]
// hi = [0]
// W = []
// }
w := WavefrontComponent{
w := &WavefrontComponent{
lo: &PositiveSlice[int]{
data: []int{0},
valid: []bool{true},

View File

@ -95,7 +95,7 @@ func SafeArgMin[T constraints.Integer](valids []bool, values []T) (bool, int) {
}
}
func NextLoHi(M WavefrontComponent, I WavefrontComponent, D WavefrontComponent, score int, penalties Penalty) (int, int) {
func NextLoHi(M *WavefrontComponent, I *WavefrontComponent, D *WavefrontComponent, score int, penalties Penalty) (int, int) {
x := penalties.X
o := penalties.O
e := penalties.E
@ -125,7 +125,7 @@ func NextLoHi(M WavefrontComponent, I WavefrontComponent, D WavefrontComponent,
return lo, hi
}
func NextI(M WavefrontComponent, I WavefrontComponent, score int, k int, penalties Penalty) {
func NextI(M *WavefrontComponent, I *WavefrontComponent, score int, k int, penalties Penalty) {
o := penalties.O
e := penalties.E
@ -139,7 +139,7 @@ func NextI(M WavefrontComponent, I WavefrontComponent, score int, k int, penalti
}
}
func NextD(M WavefrontComponent, D WavefrontComponent, score int, k int, penalties Penalty) {
func NextD(M *WavefrontComponent, D *WavefrontComponent, score int, k int, penalties Penalty) {
o := penalties.O
e := penalties.E
@ -153,7 +153,7 @@ func NextD(M WavefrontComponent, D WavefrontComponent, score int, k int, penalti
}
}
func NextM(M WavefrontComponent, I WavefrontComponent, D WavefrontComponent, score int, k int, penalties Penalty) {
func NextM(M *WavefrontComponent, I *WavefrontComponent, D *WavefrontComponent, score int, k int, penalties Penalty) {
x := penalties.X
a_ok, a, _ := M.GetVal(score-x, k)

View File

@ -38,7 +38,7 @@ func WFAlign(s1 string, s2 string, penalties Penalty, doCIGAR bool) Result {
}
}
func WFExtend(M WavefrontComponent, s1 string, n int, s2 string, m int, score int) {
func WFExtend(M *WavefrontComponent, s1 string, n int, s2 string, m int, score int) {
_, lo, hi := M.GetLoHi(score)
for k := lo; k <= hi; k++ {
// v = M[score][k] - k
@ -60,7 +60,7 @@ func WFExtend(M WavefrontComponent, s1 string, n int, s2 string, m int, score in
}
}
func WFNext(M WavefrontComponent, I WavefrontComponent, D WavefrontComponent, score int, penalties Penalty) {
func WFNext(M *WavefrontComponent, I *WavefrontComponent, D *WavefrontComponent, score int, penalties Penalty) {
// get this score's lo, hi
lo, hi := NextLoHi(M, I, D, score, penalties)
@ -71,7 +71,7 @@ func WFNext(M WavefrontComponent, I WavefrontComponent, D WavefrontComponent, sc
}
}
func WFBacktrace(M WavefrontComponent, I WavefrontComponent, D WavefrontComponent, score int, penalties Penalty, A_k int, A_offset uint32, s1 string, s2 string) string {
func WFBacktrace(M *WavefrontComponent, I *WavefrontComponent, D *WavefrontComponent, score int, penalties Penalty, A_k int, A_offset uint32, s1 string, s2 string) string {
x := penalties.X
o := penalties.O
e := penalties.E