@@ -3,7 +3,7 @@ use std::collections::hash_map::Entry;
33use rspack_collections:: { IdentifierMap , UkeyMap } ;
44use rspack_error:: Result ;
55use rspack_hash:: RspackHashDigest ;
6- use rustc_hash:: { FxHashMap as HashMap , FxHashSet as HashSet } ;
6+ use rustc_hash:: FxHashMap as HashMap ;
77use swc_core:: ecma:: atoms:: Atom ;
88
99use crate :: {
@@ -789,18 +789,19 @@ impl<'a> ModuleGraph<'a> {
789789 exports_info. get_export_info ( self , export_name)
790790 }
791791
792- pub ( crate ) fn get_ordered_connections (
792+ pub ( crate ) fn get_ordered_all_dependencies (
793793 & self ,
794794 module_identifier : & ModuleIdentifier ,
795- ) -> Option < Vec < & DependencyId > > {
795+ ) -> impl Iterator < Item = & DependencyId > {
796796 self
797797 . module_graph_module_by_identifier ( module_identifier)
798798 . map ( |m| {
799799 m. all_dependencies
800800 . iter ( )
801801 . filter ( |dep_id| self . connection_by_dependency_id ( dep_id) . is_some ( ) )
802- . collect ( )
803802 } )
803+ . into_iter ( )
804+ . flatten ( )
804805 }
805806
806807 pub fn connection_by_dependency_id (
@@ -848,7 +849,7 @@ impl<'a> ModuleGraph<'a> {
848849
849850 pub fn is_optional ( & self , module_id : & ModuleIdentifier ) -> bool {
850851 let mut has_connections = false ;
851- for connection in self . get_incoming_connections ( module_id) . iter ( ) {
852+ for connection in self . get_incoming_connections ( module_id) {
852853 let Some ( dependency) = self
853854 . dependency_by_id ( & connection. dependency_id )
854855 . and_then ( |dep| dep. as_module_dependency ( ) )
@@ -886,33 +887,33 @@ impl<'a> ModuleGraph<'a> {
886887 pub fn get_outgoing_connections (
887888 & self ,
888889 module_id : & ModuleIdentifier ,
889- ) -> HashSet < & ModuleGraphConnection > {
890+ ) -> impl Iterator < Item = & ModuleGraphConnection > + Clone {
890891 self
891892 . module_graph_module_by_identifier ( module_id)
892893 . map ( |mgm| {
893894 mgm
894895 . outgoing_connections ( )
895896 . iter ( )
896897 . filter_map ( |id| self . connection_by_dependency_id ( id) )
897- . collect ( )
898898 } )
899- . unwrap_or_default ( )
899+ . into_iter ( )
900+ . flatten ( )
900901 }
901902
902903 pub fn get_incoming_connections (
903904 & self ,
904905 module_id : & ModuleIdentifier ,
905- ) -> HashSet < & ModuleGraphConnection > {
906+ ) -> impl Iterator < Item = & ModuleGraphConnection > + Clone {
906907 self
907908 . module_graph_module_by_identifier ( module_id)
908909 . map ( |mgm| {
909910 mgm
910911 . incoming_connections ( )
911912 . iter ( )
912913 . filter_map ( |id| self . connection_by_dependency_id ( id) )
913- . collect ( )
914914 } )
915- . unwrap_or_default ( )
915+ . into_iter ( )
916+ . flatten ( )
916917 }
917918
918919 pub fn get_module_hash ( & self , module_id : & ModuleIdentifier ) -> Option < & RspackHashDigest > {
0 commit comments