mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
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:
parent
14e8815753
commit
f093260029
1 changed files with 1 additions and 13 deletions
|
|
@ -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)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue