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

vlib,cgen: cleanup array inits using `.repeat() instead of new init syntax

This commit is contained in:
Emily Hudson
2020-06-27 20:46:04 +01:00
committed by GitHub
parent 2669610be9
commit c84bafbdae
31 changed files with 52 additions and 53 deletions

View File

@ -595,7 +595,7 @@ fn (s string) index_kmp(p string) int {
if p.len > s.len {
return -1
}
mut prefix := [0].repeat(p.len)
mut prefix := []int{len:p.len}
mut j := 0
for i := 1; i < p.len; i++ {
for p.str[j] != p.str[i] && j > 0 {
@ -1326,7 +1326,7 @@ pub fn (s string) bytes() []byte {
if s.len == 0 {
return []
}
mut buf := [byte(0)].repeat(s.len)
mut buf := []byte{ len:s.len }
C.memcpy(buf.data, s.str, s.len)
return buf
}