mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-24 06:34:09 +00:00
Refactor code for improved readability by consolidating multi-line statements into single lines across various modules, including JSON serialization, snapshot middleware, and file name validation.
This commit is contained in:
parent
4caac7a31c
commit
2dfcac4ef7
8 changed files with 32 additions and 25 deletions
|
|
@ -57,10 +57,7 @@ impl AdjacentMetadata {
|
|||
// when encodeWindowsInvalidChars is enabled.
|
||||
// Strip known script type suffixes (.server, .client, .plugin) to get
|
||||
// the base name for the meta file.
|
||||
let file_stem = path
|
||||
.file_stem()
|
||||
.and_then(|s| s.to_str())
|
||||
.unwrap_or("");
|
||||
let file_stem = path.file_stem().and_then(|s| s.to_str()).unwrap_or("");
|
||||
let base_name = file_stem
|
||||
.strip_suffix(".server")
|
||||
.or_else(|| file_stem.strip_suffix(".client"))
|
||||
|
|
|
|||
|
|
@ -58,11 +58,7 @@ pub fn syncback_rbxm<'sync>(
|
|||
serialized
|
||||
} else {
|
||||
// Clone the subtree, filtering out ignored instances
|
||||
let filtered_tree = clone_tree_filtered(
|
||||
snapshot.new_tree(),
|
||||
inst.referent(),
|
||||
&tree_globs,
|
||||
);
|
||||
let filtered_tree = clone_tree_filtered(snapshot.new_tree(), inst.referent(), &tree_globs);
|
||||
let mut serialized = Vec::new();
|
||||
rbx_binary::to_writer(&mut serialized, &filtered_tree, &[filtered_tree.root_ref()])
|
||||
.context("failed to serialize filtered rbxm")?;
|
||||
|
|
@ -99,7 +95,9 @@ fn add_children_filtered(
|
|||
builder: &mut InstanceBuilder,
|
||||
ignore_globs: &[Glob],
|
||||
) {
|
||||
let parent = source.get_by_ref(parent_ref).expect("parent ref should exist");
|
||||
let parent = source
|
||||
.get_by_ref(parent_ref)
|
||||
.expect("parent ref should exist");
|
||||
|
||||
for &child_ref in parent.children() {
|
||||
let child_path = inst_path(source, child_ref);
|
||||
|
|
@ -112,7 +110,9 @@ fn add_children_filtered(
|
|||
continue;
|
||||
}
|
||||
|
||||
let child = source.get_by_ref(child_ref).expect("child ref should exist");
|
||||
let child = source
|
||||
.get_by_ref(child_ref)
|
||||
.expect("child ref should exist");
|
||||
|
||||
let mut child_builder = InstanceBuilder::new(child.class)
|
||||
.with_name(child.name.clone())
|
||||
|
|
|
|||
|
|
@ -69,11 +69,7 @@ pub fn syncback_rbxmx<'sync>(
|
|||
serialized
|
||||
} else {
|
||||
// Clone the subtree, filtering out ignored instances
|
||||
let filtered_tree = clone_tree_filtered(
|
||||
snapshot.new_tree(),
|
||||
inst.referent(),
|
||||
&tree_globs,
|
||||
);
|
||||
let filtered_tree = clone_tree_filtered(snapshot.new_tree(), inst.referent(), &tree_globs);
|
||||
let mut serialized = Vec::new();
|
||||
rbx_xml::to_writer(
|
||||
&mut serialized,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue