mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Enhance matching module with valid children tracking and code readability improvements
- Added a `validChildren` field to the `VCache` structure to track valid child instances during the matching process. - Refactored the `cacheVirtual` function to improve readability by formatting parameters across multiple lines. - Updated the `computePairCost` function to utilize the new `validChildren` field for more accurate cost calculations. - Simplified the `matchChildren` function by removing redundant code and improving the handling of matched instances. - Enhanced test cases for the `matchChildren` function to ensure consistent behavior and validate the new changes. These updates improve the efficiency and clarity of the matching process, ensuring better performance and maintainability.
This commit is contained in:
parent
b687c8862d
commit
ddd47b9afa
9 changed files with 287 additions and 363 deletions
|
|
@ -829,29 +829,14 @@ mod tests {
|
|||
fn total_cost_includes_unmatched() {
|
||||
let mut new_dom = WeakDom::new(InstanceBuilder::new("DataModel"));
|
||||
let new_root = new_dom.root_ref();
|
||||
new_dom.insert(
|
||||
new_root,
|
||||
InstanceBuilder::new("Folder").with_name("A"),
|
||||
);
|
||||
new_dom.insert(
|
||||
new_root,
|
||||
InstanceBuilder::new("Folder").with_name("B"),
|
||||
);
|
||||
new_dom.insert(
|
||||
new_root,
|
||||
InstanceBuilder::new("Folder").with_name("C"),
|
||||
);
|
||||
new_dom.insert(new_root, InstanceBuilder::new("Folder").with_name("A"));
|
||||
new_dom.insert(new_root, InstanceBuilder::new("Folder").with_name("B"));
|
||||
new_dom.insert(new_root, InstanceBuilder::new("Folder").with_name("C"));
|
||||
|
||||
let mut old_dom = WeakDom::new(InstanceBuilder::new("DataModel"));
|
||||
let old_root = old_dom.root_ref();
|
||||
old_dom.insert(
|
||||
old_root,
|
||||
InstanceBuilder::new("Folder").with_name("A"),
|
||||
);
|
||||
old_dom.insert(
|
||||
old_root,
|
||||
InstanceBuilder::new("Folder").with_name("B"),
|
||||
);
|
||||
old_dom.insert(old_root, InstanceBuilder::new("Folder").with_name("A"));
|
||||
old_dom.insert(old_root, InstanceBuilder::new("Folder").with_name("B"));
|
||||
|
||||
let new_children: Vec<Ref> = new_dom.get_by_ref(new_root).unwrap().children().to_vec();
|
||||
let old_children: Vec<Ref> = old_dom.get_by_ref(old_root).unwrap().children().to_vec();
|
||||
|
|
|
|||
|
|
@ -61,12 +61,22 @@ pub fn filter_properties_with_stats<'inst>(
|
|||
return true;
|
||||
}
|
||||
if !sync_unscriptable {
|
||||
if let Some(data) = class_data {
|
||||
let mut current = class_data;
|
||||
loop {
|
||||
let data = match current {
|
||||
Some(d) => d,
|
||||
None => break,
|
||||
};
|
||||
if let Some(prop_data) = data.properties.get(prop_name.as_str()) {
|
||||
if matches!(prop_data.scriptability, Scriptability::None) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
current = data
|
||||
.superclass
|
||||
.as_ref()
|
||||
.and_then(|s| database.classes.get(&**s));
|
||||
}
|
||||
}
|
||||
false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue