File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -492,21 +492,21 @@ pub fn (s string) replace_each(vals []string) string {
492492 return s.clone ()
493493 }
494494 idxs.sort (a.idx < b.idx)
495- mut b := unsafe { malloc_noscan (new_len + 1 ) } // add space for 0 terminator
495+ mut buf := unsafe { malloc_noscan (new_len + 1 ) } // add space for 0 terminator
496496 // Fill the new string
497497 mut idx_pos := 0
498498 mut cur_idx := idxs[idx_pos]
499- mut b_i := 0
499+ mut buf_i := 0
500500 for i := 0 ; i < s.len; i++ {
501501 if i == cur_idx.idx {
502502 // Reached the location of rep, replace it with "with"
503503 rep := vals[cur_idx.val_idx]
504504 with := vals[cur_idx.val_idx + 1 ]
505505 for j in 0 .. with.len {
506506 unsafe {
507- b[b_i ] = with[j]
507+ buf[buf_i ] = with[j]
508508 }
509- b_i ++
509+ buf_i ++
510510 }
511511 // Skip the length of rep, since we just replaced it with "with"
512512 i + = rep.len - 1
@@ -518,14 +518,14 @@ pub fn (s string) replace_each(vals []string) string {
518518 } else {
519519 // Rep doesnt start here, just copy
520520 unsafe {
521- b[b_i ] = s.str[i]
521+ buf[buf_i ] = s.str[i]
522522 }
523- b_i ++
523+ buf_i ++
524524 }
525525 }
526526 unsafe {
527- b [new_len] = 0
528- return tos (b , new_len)
527+ buf [new_len] = 0
528+ return tos (buf , new_len)
529529 }
530530}
531531
You can’t perform that action at this time.
0 commit comments