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

@@ -40,8 +40,8 @@ mut:
}
fn (mut d Digest) reset() {
d.x = [byte(0)].repeat(chunk)
d.h = [u32(0)].repeat(5)
d.x = []byte{len:(chunk)}
d.h = []u32{len:(5)}
d.h[0] = u32(init0)
d.h[1] = u32(init1)
d.h[2] = u32(init2)
@@ -105,7 +105,7 @@ pub fn (d &Digest) sum(b_in []byte) []byte {
fn (mut d Digest) checksum() []byte {
mut len := d.len
// Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.
mut tmp := [byte(0)].repeat(64)
mut tmp := []byte{len:(64)}
tmp[0] = 0x80
@@ -120,7 +120,7 @@ fn (mut d Digest) checksum() []byte {
binary.big_endian_put_u64(mut tmp, len)
d.write(tmp[..8])
mut digest := [byte(0)].repeat(size)
mut digest := []byte{len:(size)}
binary.big_endian_put_u32(mut digest, d.h[0])
binary.big_endian_put_u32(mut digest[4..], d.h[1])

View File

@@ -19,7 +19,7 @@ const (
fn block_generic(mut dig Digest, p_ []byte) {
mut p := p_
mut w := [u32(0)].repeat(16)
mut w := []u32{len:(16)}
mut h0 := dig.h[0]
mut h1 := dig.h[1]
mut h2 := dig.h[2]