Skip to content

Commit

Permalink
ci: fix -cstrict builds with clang-18, remove obsolete TODO comment
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed May 24, 2024
1 parent 662cd81 commit 69c04f0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions vlib/builtin/string.v
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,12 @@ pub fn (s string) replace(rep string, with string) string {
if !s.contains(rep) {
return s.clone()
}
// TODO: PERF Allocating ints is expensive. Should be a stack array
// Get locations of all reps within this string
mut pidxs_len := 0
pidxs_cap := s.len / rep.len
mut stack_idxs := [replace_stack_buffer_size]int{}
mut pidxs := unsafe { &stack_idxs[0] }
if pidxs_cap > replace_stack_buffer_size {
pidxs = unsafe { malloc(sizeof(int) * pidxs_cap) }
pidxs = unsafe { &int(malloc(sizeof(int) * pidxs_cap)) }
}
defer {
if pidxs_cap > replace_stack_buffer_size {
Expand Down Expand Up @@ -1262,7 +1260,7 @@ fn (s string) index_kmp(p string) int {
mut stack_prefixes := [kmp_stack_buffer_size]int{}
mut p_prefixes := unsafe { &stack_prefixes[0] }
if p.len > kmp_stack_buffer_size {
p_prefixes = unsafe { vcalloc(p.len * sizeof(int)) }
p_prefixes = unsafe { &int(vcalloc(p.len * sizeof(int))) }
}
defer {
if p.len > kmp_stack_buffer_size {
Expand Down

0 comments on commit 69c04f0

Please sign in to comment.