@@ -23,15 +23,14 @@ pub fn inline(doc: &Document, inline_selection: InlineSelection, diag: &mut Buil
23
23
fn inline_components_recursively (
24
24
component : & Rc < Component > ,
25
25
roots : & HashSet < ByAddress < Rc < Component > > > ,
26
- used_once : & HashSet < ByAddress < Rc < Component > > > ,
27
26
inline_selection : InlineSelection ,
28
27
diag : & mut BuildDiagnostics ,
29
28
) {
30
29
recurse_elem_no_borrow ( & component. root_element , & ( ) , & mut |elem, _| {
31
30
let base = elem. borrow ( ) . base_type . clone ( ) ;
32
31
if let ElementType :: Component ( c) = base {
33
32
// First, make sure that the component itself is properly inlined
34
- inline_components_recursively ( & c, roots, used_once , inline_selection, diag) ;
33
+ inline_components_recursively ( & c, roots, inline_selection, diag) ;
35
34
36
35
if c. parent_element . upgrade ( ) . is_some ( ) {
37
36
// We should not inline a repeated element
@@ -49,27 +48,24 @@ pub fn inline(doc: &Document, inline_selection: InlineSelection, diag: &mut Buil
49
48
|| component. parent_element . upgrade ( ) . is_none ( ) && Rc :: ptr_eq ( elem, & component. root_element )
50
49
// We always inline other roots as a component can't be both a sub component and a root
51
50
|| roots. contains ( & ByAddress ( c. clone ( ) ) )
52
- || used_once. contains ( & ByAddress ( c. clone ( ) ) )
53
51
}
54
52
} {
55
53
inline_element ( elem, & c, component, diag) ;
56
54
}
57
55
}
58
56
} ) ;
59
57
component. popup_windows . borrow ( ) . iter ( ) . for_each ( |p| {
60
- inline_components_recursively ( & p. component , roots, used_once , inline_selection, diag)
58
+ inline_components_recursively ( & p. component , roots, inline_selection, diag)
61
59
} )
62
60
}
63
61
let mut roots = HashSet :: new ( ) ;
64
- let mut used_once = HashSet :: new ( ) ;
65
62
if inline_selection == InlineSelection :: InlineOnlyRequiredComponents {
66
63
for component in doc. exported_roots ( ) . chain ( doc. popup_menu_impl . iter ( ) . cloned ( ) ) {
67
64
roots. insert ( ByAddress ( component. clone ( ) ) ) ;
68
65
}
69
- used_once = collect_subcomponents_used_once ( doc) ;
70
66
}
71
67
for component in doc. exported_roots ( ) . chain ( doc. popup_menu_impl . iter ( ) . cloned ( ) ) {
72
- inline_components_recursively ( & component, & roots, & used_once , inline_selection, diag) ;
68
+ inline_components_recursively ( & component, & roots, inline_selection, diag) ;
73
69
let mut init_code = component. init_code . borrow_mut ( ) ;
74
70
let inlined_init_code = core:: mem:: take ( & mut init_code. inlined_init_code ) ;
75
71
init_code. constructor_code . splice ( 0 ..0 , inlined_init_code. into_values ( ) ) ;
@@ -655,35 +651,3 @@ fn element_require_inlining(elem: &ElementRc) -> bool {
655
651
656
652
false
657
653
}
658
-
659
- fn collect_subcomponents_used_once ( doc : & Document ) -> HashSet < ByAddress < Rc < Component > > > {
660
- fn recursive ( component : & Rc < Component > , hash : & mut HashMap < ByAddress < Rc < Component > > , bool > ) {
661
- match hash. entry ( ByAddress ( component. clone ( ) ) ) {
662
- std:: collections:: hash_map:: Entry :: Occupied ( mut o) => {
663
- if !* o. get ( ) {
664
- // We have already set this element (and its children to "set multiple times"
665
- return ;
666
- }
667
- // Element used multiple times, visit all children to set them to multiple times too.
668
- * o. get_mut ( ) = false ;
669
- }
670
- std:: collections:: hash_map:: Entry :: Vacant ( v) => {
671
- v. insert ( true ) ;
672
- }
673
- }
674
-
675
- recurse_elem ( & component. root_element , & ( ) , & mut |elem : & ElementRc , & ( ) | {
676
- let ElementType :: Component ( base_comp) = & elem. borrow ( ) . base_type else { return } ;
677
- recursive ( base_comp, hash) ;
678
- } ) ;
679
- for popup in component. popup_windows . borrow ( ) . iter ( ) {
680
- recursive ( & popup. component , hash) ;
681
- }
682
- }
683
- // Stores true for elements that are used once, false for elements that are used multiple times;
684
- let mut result = HashMap :: new ( ) ;
685
- for component in doc. exported_roots ( ) . chain ( doc. popup_menu_impl . iter ( ) . cloned ( ) ) {
686
- recursive ( & component, & mut result) ;
687
- }
688
- result. into_iter ( ) . filter ( |( _, v) | * v) . map ( |( k, _) | k) . collect ( )
689
- }
0 commit comments