Skip to content

Commit f3884eb

Browse files
committed
Decrease peak mem usage when generating mod tree and add breaking note to changelog
1 parent 506aac6 commit f3884eb

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111

1212
### Changed
1313

14-
- Top-level APIs now return `micropb_gen::Error` instead of `io::Error`
15-
- Split `container-heapless` into `container-heapless-0-8` and `container-heapless-0-9`
16-
- Change `container-arrayvec` to `container-arrayvec-0-7`
14+
- **BREAKING:** Top-level APIs now return `micropb_gen::Error` instead of `io::Error`
15+
- **BREAKING:** Split `container-heapless` into `container-heapless-0-8` and `container-heapless-0-9`
16+
- **BREAKING:** Change `container-arrayvec` to `container-arrayvec-0-7`
1717
- `use_container_heapless` now sets `map_type` to `heapless::index_map::FnvIndexMap`, which is the correct path in v0.9
1818
- Bump MSRV to 1.88
1919

2020
### Removed
2121

22-
- Remove `micropb` re-exports of `heapless` and `arrayvec`
22+
- **BREAKING:** Remove `micropb` re-exports of `heapless` and `arrayvec`
2323

2424
## 0.5.1
2525

@@ -31,12 +31,12 @@
3131

3232
### Removed
3333

34-
- Remove `field_lifetime` config
35-
- Remove `recursive_field` config
34+
- **BREAKING:** Remove `field_lifetime` config
35+
- **BREAKING:** Remove `recursive_field` config
3636

3737
### Changed
3838

39-
- `MAX_SIZE` changed from `Option<usize>` to `Result<usize, &str>` for reporting why the max size wasn't generated
39+
- **BREAKING:** `MAX_SIZE` changed from `Option<usize>` to `Result<usize, &str>` for reporting why the max size wasn't generated
4040
- Lifetime params are now generated for parent messages if their child messages have lifetimes
4141
- Applying `no_debug_impl`, `no_clone_impl`, and `no_partial_eq_impl` on a message will also apply to all its ancestors
4242
- Recursively nested messages are automatically detected and prevented by boxing the field

micropb-gen/src/generator.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,13 @@ impl<'proto> Context<'proto> {
293293
}
294294

295295
fn generate_mod_tree(&self, mod_node: &mut Node<TokenStream>) -> TokenStream {
296-
let code = mod_node.value_mut().take().unwrap_or_default();
297-
let submods = mod_node.children_mut().map(|(submod_name, inner_node)| {
296+
let mut code = mod_node.value_mut().take().unwrap_or_default();
297+
for (submod_name, inner_node) in mod_node.children_mut() {
298298
let submod_name = resolve_path_elem(submod_name, self.params.suffixed_package_names);
299299
let inner = self.generate_mod_tree(inner_node);
300-
quote! { pub mod #submod_name { #inner } }
301-
});
302-
303-
quote! {
304-
#code
305-
#(#submods)*
300+
code.extend(quote! { pub mod #submod_name { #inner } });
306301
}
302+
code
307303
}
308304

309305
fn generate_enum(&self, e: Option<&Enum>) -> TokenStream {

0 commit comments

Comments
 (0)