builtin: optimize []rune.string()
parent
0cbc77d881
commit
26b77515b9
|
@ -2,6 +2,8 @@
|
|||
// Use of this source code is governed by an MIT license that can be found in the LICENSE file.
|
||||
module builtin
|
||||
|
||||
import strings
|
||||
|
||||
// This was never working correctly, the issue is now
|
||||
// fixed however the type checks in checker need to be
|
||||
// updated. if you uncomment it you will see the issue
|
||||
|
@ -29,11 +31,14 @@ pub fn (c rune) str() string {
|
|||
}
|
||||
|
||||
// string converts a rune array to a string
|
||||
[manualfree]
|
||||
pub fn (ra []rune) string() string {
|
||||
mut res := ''
|
||||
mut sb := strings.new_builder(ra.len)
|
||||
for r in ra {
|
||||
res += r.str()
|
||||
sb.write_string(r.str())
|
||||
}
|
||||
res := sb.str()
|
||||
unsafe { sb.free() }
|
||||
return res
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue