1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: unsafe vlib pointer indexing (#5836)

This commit is contained in:
Nick Treleaven
2020-07-15 20:56:50 +01:00
committed by GitHub
parent cc7c8009a1
commit f5e6a83a05
7 changed files with 326 additions and 189 deletions

View File

@ -488,12 +488,18 @@ pub fn (b []byte) hex() string {
mut dst_i := 0
for i in b {
n0 := i >> 4
hex[dst_i++] = if n0 < 10 { n0 + `0` } else { n0 + byte(87) }
unsafe {
hex[dst_i++] = if n0 < 10 { n0 + `0` } else { n0 + byte(87) }
}
n1 := i & 0xF
hex[dst_i++] = if n1 < 10 { n1 + `0` } else { n1 + byte(87) }
unsafe {
hex[dst_i++] = if n1 < 10 { n1 + `0` } else { n1 + byte(87) }
}
}
unsafe {
hex[dst_i] = `\0`
return tos(hex,dst_i)
}
hex[dst_i] = `\0`
return tos(hex,dst_i)
}
// copy copies the `src` byte array elements to the `dst` byte array.