mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 10:41:11 +08:00
refactor: 统一调用调度并安全化 IC 缓存
This commit is contained in:
@@ -100,16 +100,18 @@ impl ShapeForge {
|
||||
pub fn lookup_position(&self, shape_id: ShapeId, prop_name: StringIndex) -> Option<u32> {
|
||||
let shapes = self.shapes.read().unwrap();
|
||||
let total_depth = Self::compute_depth(shape_id, &shapes);
|
||||
let mut step: u32 = 0;
|
||||
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) => {
|
||||
if s.property_name == prop_name && s.property_name != EMPTY_SENTINEL {
|
||||
return Some(total_depth - step - 1);
|
||||
if s.property_name != EMPTY_SENTINEL {
|
||||
if s.property_name == prop_name {
|
||||
return total_depth.checked_sub(prop_steps + 1);
|
||||
}
|
||||
prop_steps += 1;
|
||||
}
|
||||
cursor = s.parent;
|
||||
step += 1;
|
||||
}
|
||||
None => return None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user