pub fn dead_code_optimization(
    network: &mut TriggerNetwork,
    objects: &mut Triggerlist,
    //closed_group: &mut u16,
    reserved: &ReservedIds,
) {
    for (group, gang) in network.map.clone() {
        if is_start_group(group, reserved) {
            for (i, _) in gang.triggers.iter().enumerate() {
                let mut visited = Vec::new();
                if check_for_dead_code(
                    network,
                    objects,
                    (group, i),
                    //closed_group,
                    reserved,
                    &mut visited,
                ) == DeadCodeResult::Keep
                {
                    (*network.map.get_mut(&group).unwrap()).triggers[i].deleted = false;
                }
            }
        }
    }
}
// performes a DFS from each start group, and removes all triggers that:
// - dont lead to an output trigger
// - are not reachable from a start group
performes a DFS from each start group, and removes all triggers that:
dont lead to an output trigger
are not reachable from a start group
performes a DFS from each start group and removes all triggers that : dont lead to an output trigger are not reachable from a start group
pub fn dead_code_optimization(
    network: &mut TriggerNetwork,
    objects: &mut Triggerlist,
    //closed_group: &mut u16,
    reserved: &ReservedIds,
) {
    for (group, gang) in network.map.clone() {
        if is_start_group(group, reserved) {
            for (i, _) in gang.triggers.iter().enumerate() {
                let mut visited = Vec::new();
                if check_for_dead_code(
                    network,
                    objects,
                    (group, i),
                    //closed_group,
                    reserved,
                    &mut visited,
                ) == DeadCodeResult::Keep
                {
                    (*network.map.get_mut(&group).unwrap()).triggers[i].deleted = false;
                }
            }
        }
    }
}
pub fn dead_code_optimization ( network : & mut TriggerNetwork , objects : & mut Triggerlist , //closed_group: &mut u16, reserved : & ReservedIds , ) { for ( group , gang ) in network . map . clone ( ) { if is_start_group ( group , reserved ) { for ( i , _ ) in gang . triggers . iter ( ) . enumerate ( ) { let mut visited = Vec :: new ( ) ; if check_for_dead_code ( network , objects , ( group , i ) , //closed_group, reserved , & mut visited , ) == DeadCodeResult :: Keep { ( * network . map . get_mut ( & group ) . unwrap ( ) ) . triggers [ i ] . deleted = false ; } } } } }
performes a DFS from each start group, and removes all triggers that:
 dont lead to an output trigger
 are not reachable from a start group
performes a DFS from each start group and removes all triggers that : dont lead to an output trigger are not reachable from a start group
network
&mut TriggerNetwork
objects
&mut Triggerlist
reserved
&ReservedIds