This commit is contained in:
Kovid Goyal
2025-05-21 12:16:25 +05:30
parent c158fde734
commit cc500893f0

View File

@@ -113,7 +113,7 @@ func (w *workspace_type) address_is_monotonic() bool {
func (w *workspace_type) calc_score() (ans float64) {
distance, pos := 0, 0
for i := 0; i < len(w.positions); i++ {
for i := range len(w.positions) {
pos = w.position(i)
if i == 0 {
distance = pos + 1
@@ -135,7 +135,7 @@ func (w *workspace_type) calc_score() (ans float64) {
func has_atleast_one_match(w *workspace_type) (found bool) {
p := -1
for i := 0; i < len(w.positions); i++ {
for i := range len(w.positions) {
if len(w.positions[i]) == 0 { // all chars of needle not in haystack
return false
}
@@ -159,9 +159,9 @@ func score_item(item string, idx int, needle []rune, opts *resolved_options_type
haystack := []rune(strings.ToLower(item))
orig_haystack := []rune(item)
w.initialize(len(orig_haystack), len(needle))
for i := 0; i < len(haystack); i++ {
for i := range len(haystack) {
level_factor_calculated := false
for j := 0; j < len(needle); j++ {
for j := range len(needle) {
if needle[j] == haystack[i] {
if !level_factor_calculated {
level_factor_calculated = true