diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index dd090b94b9..77e747f814 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -2868,20 +2868,16 @@ pub fn (s string) hex() string { @[unsafe] fn data_to_hex_string(data &u8, len int) string { - mut hex := unsafe { malloc_noscan(u64(len) * 2 + 1) } + mut hex := malloc_noscan(u64(len) * 2 + 1) mut dst := 0 for c in 0 .. len { b := data[c] n0 := b >> 4 n1 := b & 0xF - unsafe { - hex[dst] = if n0 < 10 { n0 + `0` } else { n0 + `W` } - hex[dst + 1] = if n1 < 10 { n1 + `0` } else { n1 + `W` } - } + hex[dst] = if n0 < 10 { n0 + `0` } else { n0 + `W` } + hex[dst + 1] = if n1 < 10 { n1 + `0` } else { n1 + `W` } dst += 2 } - unsafe { - hex[dst] = 0 - return tos(hex, dst) - } + hex[dst] = 0 + return tos(hex, dst) }