mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
builtin,v: reduce overhead and memory usage for very frequently called methods (#21540)
This commit is contained in:
parent
9997ac4367
commit
84fbe2728d
10 changed files with 70 additions and 41 deletions
|
@ -212,38 +212,45 @@ fn (data &StrIntpData) process_str_intp_data(mut sb strings.Builder) {
|
|||
unsafe {
|
||||
// strings
|
||||
if typ == .si_s {
|
||||
mut s := ''
|
||||
if upper_case {
|
||||
s = data.d.d_s.to_upper()
|
||||
s := data.d.d_s.to_upper()
|
||||
if width == 0 {
|
||||
sb.write_string(s)
|
||||
} else {
|
||||
strconv.format_str_sb(s, bf, mut sb)
|
||||
}
|
||||
s.free()
|
||||
} else {
|
||||
s = data.d.d_s.clone()
|
||||
if width == 0 {
|
||||
sb.write_string(data.d.d_s)
|
||||
} else {
|
||||
strconv.format_str_sb(data.d.d_s, bf, mut sb)
|
||||
}
|
||||
}
|
||||
if width == 0 {
|
||||
sb.write_string(s)
|
||||
} else {
|
||||
strconv.format_str_sb(s, bf, mut sb)
|
||||
}
|
||||
s.free()
|
||||
return
|
||||
}
|
||||
|
||||
if typ == .si_r {
|
||||
if width > 0 {
|
||||
mut s := ''
|
||||
if upper_case {
|
||||
s = data.d.d_s.to_upper()
|
||||
s := data.d.d_s.to_upper()
|
||||
for _ in 1 .. (1 + (if width > 0 {
|
||||
width
|
||||
} else {
|
||||
0
|
||||
})) {
|
||||
sb.write_string(s)
|
||||
}
|
||||
s.free()
|
||||
} else {
|
||||
s = data.d.d_s.clone()
|
||||
for _ in 1 .. (1 + (if width > 0 {
|
||||
width
|
||||
} else {
|
||||
0
|
||||
})) {
|
||||
sb.write_string(data.d.d_s)
|
||||
}
|
||||
}
|
||||
|
||||
for _ in 1 .. (1 + (if width > 0 {
|
||||
width
|
||||
} else {
|
||||
0
|
||||
})) {
|
||||
sb.write_string(s)
|
||||
}
|
||||
s.free()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue