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

@ -256,14 +256,14 @@ fn escape(s string, mode EncodingMode) string {
if space_count == 0 && hex_count == 0 {
return s
}
buf := [byte(0)].repeat(64)
buf := []byte{len:(64)}
mut t := []byte{}
required := s.len + 2 * hex_count
if required <= buf.len {
t = buf[..required]
}
else {
t = [byte(0)].repeat(required)
t = []byte{len:(required)}
}
if hex_count == 0 {
copy(t, s.bytes())