builtin: use malloc_noscan more (for map metas and in []byte.hex())
parent
1993bf2a12
commit
8dc4b1d9a3
|
@ -791,7 +791,7 @@ pub fn (a []string) str() string {
|
||||||
// hex returns a string with the hexadecimal representation
|
// hex returns a string with the hexadecimal representation
|
||||||
// of the byte elements of the array.
|
// of the byte elements of the array.
|
||||||
pub fn (b []byte) hex() string {
|
pub fn (b []byte) hex() string {
|
||||||
mut hex := unsafe { malloc(b.len * 2 + 1) }
|
mut hex := unsafe { malloc_noscan(b.len * 2 + 1) }
|
||||||
mut dst_i := 0
|
mut dst_i := 0
|
||||||
for i in b {
|
for i in b {
|
||||||
n0 := i >> 4
|
n0 := i >> 4
|
||||||
|
|
|
@ -324,7 +324,7 @@ pub fn malloc_noscan(n int) &byte {
|
||||||
}
|
}
|
||||||
$if trace_malloc ? {
|
$if trace_malloc ? {
|
||||||
total_m += n
|
total_m += n
|
||||||
C.fprintf(C.stderr, c'_v_malloc %6d total %10d\n', n, total_m)
|
C.fprintf(C.stderr, c'malloc_noscan %6d total %10d\n', n, total_m)
|
||||||
// print_backtrace()
|
// print_backtrace()
|
||||||
}
|
}
|
||||||
mut res := &byte(0)
|
mut res := &byte(0)
|
||||||
|
|
|
@ -662,7 +662,7 @@ pub fn (m &map) clone() map {
|
||||||
cached_hashbits: m.cached_hashbits
|
cached_hashbits: m.cached_hashbits
|
||||||
shift: m.shift
|
shift: m.shift
|
||||||
key_values: unsafe { m.key_values.clone() }
|
key_values: unsafe { m.key_values.clone() }
|
||||||
metas: unsafe { &u32(malloc(metasize)) }
|
metas: unsafe { &u32(malloc_noscan(metasize)) }
|
||||||
extra_metas: m.extra_metas
|
extra_metas: m.extra_metas
|
||||||
len: m.len
|
len: m.len
|
||||||
has_string_keys: m.has_string_keys
|
has_string_keys: m.has_string_keys
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub fn (c rune) str() string {
|
||||||
println('len=$len')
|
println('len=$len')
|
||||||
mut str := string{
|
mut str := string{
|
||||||
len: len
|
len: len
|
||||||
str: malloc(len + 1)
|
str: malloc_noscan(len + 1)
|
||||||
}
|
}
|
||||||
for i in 0..len {
|
for i in 0..len {
|
||||||
str.str[i] = byte(int(c)>>8 * (3 - i) & 0xff)
|
str.str[i] = byte(int(c)>>8 * (3 - i) & 0xff)
|
||||||
|
|
Loading…
Reference in New Issue