Skip to content

Commit 48000f4

Browse files
builtin: rename b to buf in string.replace_each, to avoid sort lambda shadowing (fix compilation with older V versions) (#26510)
1 parent bc0bcd3 commit 48000f4

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

vlib/builtin/string.v

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)