perf: new_string_owned 零拷贝路径替代 new_string 二次克隆(B2)

This commit is contained in:
2026-08-13 14:55:08 +08:00
parent 5513f0e2fb
commit 3ae2f2d9b7
10 changed files with 42 additions and 37 deletions
+2 -2
View File
@@ -213,7 +213,7 @@ pub fn number_to_string<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
if neg {
result.insert(0, '-');
}
NativeResult::Ok(vm.new_string(&result))
NativeResult::Ok(vm.new_string_owned(result))
}
/// `Number.prototype.toFixed(digits)`:固定小数位数(0..100)输出字符串,
@@ -330,7 +330,7 @@ pub fn number_to_exponential<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult
}
}
let result = format!("{}{}", sign_prefix, s);
return NativeResult::Ok(vm.new_string(&result));
return NativeResult::Ok(vm.new_string_owned(result));
}
let raw = oxide_runtime_api::to_integer_or_infinity(vm.reg(args[1]));
if !(0.0..=100.0).contains(&raw) {