File tree Expand file tree Collapse file tree 1 file changed +4
-13
lines changed
consensus/proto_array/src Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change @@ -1060,19 +1060,10 @@ impl ProtoArray {
1060
1060
1061
1061
/// Returns all node indices that have zero children. May include unviable nodes.
1062
1062
fn nodes_without_children ( & self ) -> Vec < usize > {
1063
- let mut childs_of = HashMap :: < _ , Vec < _ > > :: new ( ) ;
1064
- for ( index, node) in self . nodes . iter ( ) . enumerate ( ) {
1065
- // Create entry for this node
1066
- childs_of. entry ( index) . or_default ( ) ;
1067
- // Add this node to the parent's child list if any
1068
- if let Some ( parent_index) = node. parent {
1069
- childs_of. entry ( parent_index) . or_default ( ) . push ( index) ;
1070
- }
1071
- }
1072
- childs_of
1073
- . into_iter ( )
1074
- . filter ( |( _, childs) | childs. is_empty ( ) )
1075
- . map ( |( index, _) | index)
1063
+ self . nodes
1064
+ . iter ( )
1065
+ . enumerate ( )
1066
+ . filter_map ( |( i, node) | node. best_child . is_none ( ) . then_some ( i) )
1076
1067
. collect ( )
1077
1068
}
1078
1069
}
You can’t perform that action at this time.
0 commit comments