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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user