mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
perf: typeof 改 js_type 单次提取并复用进程级静态字符串消除每次分配
This commit is contained in:
@@ -16,9 +16,10 @@ fn eval(source: &str) -> Result<(Vm, JsValue), String> {
|
||||
}
|
||||
|
||||
fn eval_str(source: &str) -> Result<String, String> {
|
||||
let (_vm, v) = eval(source)?;
|
||||
let (vm, v) = eval(source)?;
|
||||
// 字符串结果须在同一 VM 上读:perm 串指向 VM 私有内核,VM drop 后指针悬垂。
|
||||
if v.is_string() {
|
||||
Ok(oxide_runtime_api::to_string(v))
|
||||
Ok(vm.lookup_str(v).unwrap_or_default())
|
||||
} else {
|
||||
Ok(format!("{v}"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user