mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: reduce allocations in rune.bytes()
This commit is contained in:
@@ -54,8 +54,11 @@ pub fn (c rune) repeat(count int) string {
|
||||
return res.repeat(count)
|
||||
}
|
||||
|
||||
[manualfree]
|
||||
pub fn (c rune) bytes() []byte {
|
||||
return c.str().bytes()
|
||||
mut res := []byte{cap: 5}
|
||||
res.len = unsafe { utf32_decode_to_buffer(u32(c), &byte(res.data)) }
|
||||
return res
|
||||
}
|
||||
|
||||
pub fn (c rune) length_in_bytes() int {
|
||||
|
||||
Reference in New Issue
Block a user