@@ -164,7 +164,7 @@ fn get_dep_modules(
164
164
package_modules : & AHashSet < String > ,
165
165
valid_modules : & AHashSet < String > ,
166
166
) -> AHashSet < String > {
167
- let mut deps = Vec :: new ( ) ;
167
+ let mut deps = AHashSet :: new ( ) ;
168
168
if let Ok ( lines) = helpers:: read_lines ( ast_file. to_string ( ) ) {
169
169
// we skip the first line with is some null characters
170
170
// the following lines in the AST are the dependency modules
@@ -177,7 +177,7 @@ fn get_dep_modules(
177
177
if line. starts_with ( '/' ) {
178
178
break ;
179
179
} else if !line. is_empty ( ) {
180
- deps. push ( line) ;
180
+ deps. insert ( line) ;
181
181
}
182
182
}
183
183
Err ( _) => ( ) ,
@@ -186,29 +186,28 @@ fn get_dep_modules(
186
186
}
187
187
188
188
return deps
189
- . into_iter ( )
189
+ . iter ( )
190
190
. map ( |dep| {
191
- dep. split ( '.' )
192
- . collect :: < Vec < & str > > ( )
193
- . first ( )
194
- . unwrap ( )
195
- . to_string ( )
196
- } )
197
- . map ( |dep| match namespace. to_owned ( ) {
198
- Some ( namespace) => {
199
- let namespaced_name = dep. to_owned ( ) + "-" + & namespace;
200
- if package_modules. contains ( & namespaced_name) {
201
- return namespaced_name;
202
- } else {
203
- return dep;
204
- } ;
191
+ let dep_first = dep. split ( '.' ) . next ( ) . unwrap ( ) ;
192
+
193
+ match & namespace {
194
+ Some ( namespace) => {
195
+ let namespaced_name = dep_first. to_owned ( ) + "-" + & namespace;
196
+ if package_modules. contains ( & namespaced_name) {
197
+ return namespaced_name;
198
+ } else {
199
+ return dep_first. to_string ( ) ;
200
+ } ;
201
+ }
202
+ None => dep_first. to_string ( ) ,
205
203
}
206
- None => dep,
207
204
} )
208
- . filter ( |dep| valid_modules. contains ( dep) )
209
- . filter ( |dep| match namespace. to_owned ( ) {
210
- Some ( namespace) => !dep. eq ( & namespace) ,
211
- None => true ,
205
+ . filter ( |dep| {
206
+ valid_modules. contains ( dep)
207
+ && match namespace. to_owned ( ) {
208
+ Some ( namespace) => !dep. eq ( & namespace) ,
209
+ None => true ,
210
+ }
212
211
} )
213
212
. collect :: < AHashSet < String > > ( ) ;
214
213
}
0 commit comments