Skip to content
Myr

Remove unused clear arguments of alloc16 and alloc32

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent a2a4df0 · Browse files · 1 file+7 added−17 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−17 removed

  • other:+7 added−17 removed

1 file+7 added−17 removed

modified:src/algo/algo.go+7 added-17 removed
156 unmodified lines
157 }158 return nil159}160161func alloc16(offset int, slab *util.Slab, size int, clear bool) (int, []int16) {161func alloc16(offset int, slab *util.Slab, size int) (int, []int16) {162 if slab != nil && cap(slab.I16) > offset+size {163 slice := slab.I16[offset : offset+size]164 if clear {165 for idx := range slice {166 slice[idx] = 0167 }168 }164 return offset + size, slice165 }166 return offset, make([]int16, size)167}168174func alloc32(offset int, slab *util.Slab, size int, clear bool) (int, []int32) {169func alloc32(offset int, slab *util.Slab, size int) (int, []int32) {170 if slab != nil && cap(slab.I32) > offset+size {171 slice := slab.I32[offset : offset+size]177 if clear {178 for idx := range slice {179 slice[idx] = 0180 }181 }172 return offset + size, slice173 }174 return offset, make([]int32, size)175}
152 unmodified lines
328 // Reuse pre-allocated integer slice to avoid unnecessary sweeping of garbages329 offset16 := 0330 offset32 := 0331 // Bonus point for each position342 offset16, B := alloc16(offset16, slab, N, false)332 offset16, B := alloc16(offset16, slab, N)333 // The first occurrence of each character in the pattern344 offset32, F := alloc32(offset32, slab, M, false)334 offset32, F := alloc32(offset32, slab, M)335 // Rune array346 offset32, T := alloc32(offset32, slab, N, false)336 offset32, T := alloc32(offset32, slab, N)337338 // Phase 2. Calculate bonus for each point339 pidx, lastIdx, prevClass := 0, 0, charNonWord340 input.CopyRunes(T)
49 unmodified lines
390391 // Phase 3. Fill in score matrix (H)392 // Unlike the original algorithm, we do not allow omission.393 width := lastIdx - int(F[0]) + 1404 offset16, H := alloc16(offset16, slab, width*M, false)394 offset16, H := alloc16(offset16, slab, width*M)395396 // Possible length of consecutive chunk at each position.407 offset16, C := alloc16(offset16, slab, width*M, false)397 offset16, C := alloc16(offset16, slab, width*M)398399 maxScore, maxScorePos := int16(0), 0400 for i := 0; i < M; i++ {401 I := i * width
421 unmodified lines