1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cleanup: replace C for loops with range

This commit is contained in:
spaceface777
2020-02-24 17:55:16 +01:00
committed by GitHub
parent 5918946feb
commit ef8c1203b4
50 changed files with 168 additions and 170 deletions

View File

@ -47,7 +47,7 @@ pub fn (a array) repeat(nr_repeats int) array {
element_size: a.element_size
data: malloc(nr_repeats * a.len * a.element_size)
}
for i := 0; i < nr_repeats; i++ {
for i in 0..nr_repeats {
mem_copy(arr.data + i * a.len * a.element_size, a.data, a.len * a.element_size)
}
return arr

View File

@ -28,10 +28,10 @@ fn (s string) add(a string) string {
len: new_len
str: malloc(new_len + 1)
}
for j := 0; j < s.len; j++ {
for j in 0..s.len {
res[j] = s[j]
}
for j := 0; j < a.len; j++ {
for j in 0..a.len {
res[s.len + j] = a[j]
}
res[new_len] = `\0`// V strings are not null terminated, but just in case