Skip to content
Myr

Extract debug code from FuzzyMatchV2

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 302cc55 · Browse files · 1 file+35 added−26 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+35 added−26 removed

  • other:+35 added−26 removed

1 file+35 added−26 removed

modified:src/algo/algo.go+35 added-26 removed
300 unmodified lines
301 }302 return firstIdx303}304305func debugV2(T []rune, pattern []rune, F []int32, lastIdx int, H []int16, C []int16) {306 width := lastIdx - int(F[0]) + 1307308 for i, f := range F {309 I := i * width310 if i == 0 {311 fmt.Print(" ")312 for j := int(f); j <= lastIdx; j++ {313 fmt.Printf(" " + string(T[j]) + " ")314 }315 fmt.Println()316 }317 fmt.Print(string(pattern[i]) + " ")318 for idx := int(F[0]); idx < int(f); idx++ {319 fmt.Print(" 0 ")320 }321 for idx := int(f); idx <= lastIdx; idx++ {322 fmt.Printf("%2d ", H[i*width+idx-int(F[0])])323 }324 fmt.Println()325326 fmt.Print(" ")327 for idx, p := range C[I : I+width] {328 if idx+int(F[0]) < int(F[i]) {329 p = 0330 }331 fmt.Printf("%2d ", p)332 }333 fmt.Println()334 }335}336337func FuzzyMatchV2(caseSensitive bool, normalize bool, forward bool, input *util.Chars, pattern []rune, withPos bool, slab *util.Slab) (Result, *[]int) {338 // Assume that pattern is given in lowercase if case-insensitive.339 // First check if there's a match and calculate bonus for each position.340 // If the input string is too long, consider finding the matching chars in
138 unmodified lines
479 maxScore, maxScorePos = score, j480 }481 H[I+j0] = score482 }483 }484452 if DEBUG {453 if i == 0 {454 fmt.Print(" ")455 for j := int(F[i]); j <= lastIdx; j++ {456 fmt.Printf(" " + string(T[j]) + " ")457 }458 fmt.Println()459 }460 fmt.Print(string(pattern[i]) + " ")461 for idx := int(F[0]); idx < int(F[i]); idx++ {462 fmt.Print(" 0 ")463 }464 for idx := int(F[i]); idx <= lastIdx; idx++ {465 fmt.Printf("%2d ", H[i*width+idx-int(F[0])])466 }467 fmt.Println()468469 fmt.Print(" ")470 for idx, p := range C[I : I+width] {471 if idx+int(F[0]) < int(F[i]) {472 p = 0473 }474 fmt.Printf("%2d ", p)475 }476 fmt.Println()477 }485 if DEBUG {486 debugV2(T, pattern, F, lastIdx, H, C)487 }488489 // Phase 4. (Optional) Backtrace to find character positions490 pos := posArray(withPos, M)
341 unmodified lines