refactor: match 可改 ? 的等价改写

This commit is contained in:
2026-08-16 14:04:25 +08:00
parent fd2b290927
commit 1a244398f1
3 changed files with 21 additions and 33 deletions
+1 -5
View File
@@ -185,8 +185,7 @@ impl ShapeForge {
let mut prop_steps: u32 = 0;
let mut cursor = Some(shape_id);
while let Some(id) = cursor {
match shapes.get((id - 1) as usize).and_then(|s| s.clone()) {
Some(s) => {
let s = shapes.get((id - 1) as usize).and_then(|s| s.clone())?;
if s.property_name != EMPTY_SENTINEL {
if s.property_name == prop_name {
let pos = total_depth.checked_sub(prop_steps + 1)?;
@@ -198,9 +197,6 @@ impl ShapeForge {
}
cursor = s.parent;
}
None => return None,
}
}
None
}
+1 -5
View File
@@ -105,17 +105,13 @@ impl ShapeStore {
let mut step: u32 = 0;
cursor = Some(shape_id);
while let Some(id) = cursor {
match self.get_shape(id) {
Some(s) => {
let s = self.get_shape(id)?;
if s.property_name == prop_name && s.property_name != EMPTY_SENTINEL {
return Some(total_depth - step - 1);
}
cursor = s.parent;
step += 1;
}
None => return None,
}
}
None
}
+1 -5
View File
@@ -492,8 +492,7 @@ impl Vm {
NativeResult::TailCall { callee, this, args } => {
// 如 bound 函数:解析尾调用,用其返回值作为构造实例
// (或回退到 derived_this)。
match self.call_function_sync(callee, this, &args) {
Ok(val) => {
let val = self.call_function_sync(callee, this, &args)?;
let instance = if val.is_object() { val } else { derived_this };
if instance.is_object() {
self.set_constructed_proto(instance, new_target_obj)?;
@@ -502,9 +501,6 @@ impl Vm {
self.regs[rd] = self.regs[254];
self.mark_super_called();
}
Err(e) => return Err(e),
}
}
}
} else if super_obj.sub_module_index() > 0 {
let sub_idx = super_obj.sub_module_index() as usize;