Refactor instance path retrieval in snapshot.rs

- Replaced the manual path construction logic in inst_path with a call to dom.full_path_of for improved efficiency and readability.
This commit is contained in:
Joe 2026-02-10 00:38:49 -06:00
parent 14e8815753
commit f093260029

View file

@ -371,19 +371,7 @@ pub fn filter_out_property(inst: &Instance, prop_name: &str) -> bool {
} }
pub fn inst_path(dom: &WeakDom, referent: Ref) -> String { pub fn inst_path(dom: &WeakDom, referent: Ref) -> String {
let mut path = Vec::new(); dom.full_path_of(referent, "/")
let mut inst = dom.get_by_ref(referent);
while let Some(instance) = inst {
path.push(instance.name.as_str());
inst = dom.get_by_ref(instance.parent());
}
// This is to avoid the root's name from appearing in the path. Not
// optimal, but should be fine.
path.pop();
path.reverse();
path.join("/")
} }
#[cfg(test)] #[cfg(test)]