Skip to content
Myr

Delay slab allocation

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 6977cf2 · Browse files · 1 file+6 added−6 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+6 added−6 removed

  • other:+6 added−6 removed

1 file+6 added−6 removed

modified:src/algo/algo.go+6 added-6 removed
327 unmodified lines
328 if slab != nil && N*M > cap(slab.I16) {329 return FuzzyMatchV1(caseSensitive, normalize, forward, input, pattern, withPos, slab)330 }331332 // Phase 1. Optimized search for ASCII string333 idx := asciiFuzzyIndex(&input, pattern, caseSensitive)334 if idx < 0 {335 return Result{-1, -1, 0}, nil336 }337338 // Reuse pre-allocated integer slice to avoid unnecessary sweeping of garbages339 offset16 := 0340 offset32 := 0341 // Bonus point for each position
2 unmodified lines
344 offset32, F := alloc32(offset32, slab, M, false)345 // Rune array346 offset32, T := alloc32(offset32, slab, N, false)347342 // Phase 1. Optimized search for ASCII string343 idx := asciiFuzzyIndex(&input, pattern, caseSensitive)344 if idx < 0 {345 return Result{-1, -1, 0}, nil346 }347348 // Phase 2. Calculate bonus for each point349 pidx, lastIdx, prevClass := 0, 0, charNonWord350 input.CopyRunes(T)351 for ; idx < N; idx++ {
481 unmodified lines