Skip to content

Commit c0562eb

Browse files
committed
refactor(ast_tools/raw_transfer): simplify generating struct deserializer preamble (#14337)
Pure refactor. Now that output is going through minifier, we can rely on it to conflate a series of variable declarations. No need to build a single variable declaration with multiple declarators any more.
1 parent 5f328fe commit c0562eb

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

tasks/ast_tools/src/generators/raw_transfer.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,7 @@ fn generate_struct(
296296
}
297297
} else {
298298
let value = if generator.dependent_field_names.contains(&field_name) {
299-
if preamble_str.is_empty() {
300-
preamble_str.push_str("const ");
301-
} else {
302-
preamble_str.push_str(",\n");
303-
}
304-
write_it!(preamble_str, "{field_name} = {value}");
299+
write_it!(preamble_str, "const {field_name} = {value};\n");
305300
&field_name
306301
} else {
307302
&value
@@ -320,10 +315,6 @@ fn generate_struct(
320315
}
321316
}
322317

323-
if !preamble_str.is_empty() {
324-
preamble_str.push(';');
325-
}
326-
327318
for preamble_part in generator.preamble {
328319
preamble_str.push_str(preamble_part.trim());
329320
}

0 commit comments

Comments
 (0)