mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Refactor error handling and improve code readability in ServeSession and applyPatch
- Enhanced error logging in ServeSession by formatting warning messages for better clarity. - Improved readability in applyPatch by restructuring conditional statements for clarity. - Simplified assertions in tests for script pruning to maintain consistency and readability. These changes aim to improve code maintainability and enhance the clarity of error messages.
This commit is contained in:
parent
9820ec6534
commit
dcd48642be
5 changed files with 25 additions and 27 deletions
|
|
@ -473,9 +473,7 @@ impl ApiService {
|
|||
let before = request.updated.len();
|
||||
request.updated.retain(|update| {
|
||||
tree.get_instance(update.id)
|
||||
.map(|inst| {
|
||||
crate::snapshot::is_script_class(inst.class_name().as_str())
|
||||
})
|
||||
.map(|inst| crate::snapshot::is_script_class(inst.class_name().as_str()))
|
||||
.unwrap_or(false)
|
||||
});
|
||||
let filtered = before - request.updated.len();
|
||||
|
|
@ -561,8 +559,7 @@ impl ApiService {
|
|||
continue;
|
||||
}
|
||||
let parent = added.parent.unwrap_or(Ref::none());
|
||||
let real_parent =
|
||||
temp_to_real.get(&parent).copied().unwrap_or(parent);
|
||||
let real_parent = temp_to_real.get(&parent).copied().unwrap_or(parent);
|
||||
if tree.get_instance(real_parent).is_none() {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -3642,10 +3639,10 @@ fn filter_subscribe_message_for_scripts<'a>(
|
|||
// in the tree but weren't part of this patch. Without injection the
|
||||
// plugin receives an orphaned script with an unknown parent.
|
||||
for id in included_ids.iter().copied().collect::<Vec<_>>() {
|
||||
if !msg.added.contains_key(&id) {
|
||||
if let std::collections::hash_map::Entry::Vacant(e) = msg.added.entry(id) {
|
||||
if let Some(tree_inst) = tree.get_instance(id) {
|
||||
let inst = instance_for_scripts_only(tree_inst, &included_ids);
|
||||
msg.added.insert(id, inst);
|
||||
e.insert(inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue