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

@ -68,7 +68,7 @@ pub fn new(size int) BitField {
output := BitField{
size: size
//field: *u32(calloc(bitnslots(size) * slot_size / 8))
field: [u32(0)].repeat(bitnslots(size))
field: []u32{len:bitnslots(size)}
}
return output
}
@ -394,7 +394,7 @@ pub fn (mut instance BitField) resize(new_size int) {
new_bitnslots := bitnslots(new_size)
old_size := instance.size
old_bitnslots := bitnslots(old_size)
mut field := [u32(0)].repeat(new_bitnslots)
mut field := []u32{len:new_bitnslots}
for i := 0; i < old_bitnslots && i < new_bitnslots; i++ {
field[i] = instance.field[i]
}