perf: parse_js_number 去 lowercase 分配 + int32 位运算直取(B2/B6)

This commit is contained in:
2026-08-13 14:48:19 +08:00
parent f874850bf7
commit 5513f0e2fb
2 changed files with 17 additions and 10 deletions
+6
View File
@@ -505,6 +505,9 @@ impl Vm {
}
pub(crate) fn coerce_int32_bounded(&mut self, value: JsValue) -> Result<i32, String> {
if value.is_int() {
return Ok(value.as_int());
}
let n = self.coerce_number_bounded(value)?;
if n == 0.0 || !n.is_finite() {
return Ok(0);
@@ -518,6 +521,9 @@ impl Vm {
}
pub(crate) fn coerce_uint32_bounded(&mut self, value: JsValue) -> Result<u32, String> {
if value.is_int() {
return Ok(value.as_int() as u32);
}
let n = self.coerce_number_bounded(value)?;
if n == 0.0 || !n.is_finite() {
return Ok(0);