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

@ -7,7 +7,7 @@ pub fn run (op fn(), label string, code Wi_si_code, status int) int {
sys_exit(0)
}
siginfo := [0].repeat(int(Sig_index.si_size))
siginfo := []int{len:int(Sig_index.si_size)}
e := sys_waitid(.p_pid, child, intptr(&siginfo[0]), .wexited, 0)

View File

@ -40,7 +40,7 @@ fn check_read_write_pipe() {
// sys_read
// sys_close
//
buffer0 := [byte(0)].repeat(128)
buffer0 := []byte{len:(128)}
buffer := byteptr(buffer0.data)
fd := [-1, -1]
@ -87,7 +87,7 @@ fn check_read_file() {
sys_close
sys_open
*/
buffer0 := [byte(0)].repeat(128)
buffer0 := []byte{len:(128)}
buffer := byteptr(buffer0.data)
test_file := "sample_text1.txt"

View File

@ -8,7 +8,7 @@ fn check_string_eq () {
}
fn check_i64_tos() {
buffer0 := [byte(0)].repeat(128)
buffer0 := []byte{len:(128)}
buffer := byteptr(buffer0.data)
s0 := i64_tos(buffer, 70, 140, 10)

View File

@ -399,7 +399,7 @@ pub fn (c byte) is_capital() bool {
}
pub fn (b []byte) clone() []byte {
mut res := [byte(0)].repeat(b.len)
mut res := []byte{len: b.len}
//mut res := make([]byte, {repeat:b.len})
for i in 0..b.len {
res[i] = b[i]

View File

@ -379,7 +379,7 @@ fn (n &mapnode) subkeys(mut keys []string, at int) int {
}
pub fn (m &SortedMap) keys() []string {
mut keys := [''].repeat(m.len)
mut keys := []string{len:m.len}
if isnil(m.root) || m.root.len == 0 {
return keys
}

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
}