@@ -369,10 +369,9 @@ impl<'a> ModuleResolutionPathRefInner<'a> {
369
369
370
370
#[ must_use]
371
371
fn is_regular_package ( & self , search_path : Self , resolver : & ResolverState ) -> bool {
372
- fn is_non_stdlib_pkg ( state : & ResolverState , path : & SystemPath ) -> bool {
373
- let file_system = state. system ( ) ;
374
- file_system. path_exists ( & path. join ( "__init__.py" ) )
375
- || file_system. path_exists ( & path. join ( "__init__.pyi" ) )
372
+ fn is_non_stdlib_pkg ( resolver : & ResolverState , path : & SystemPath ) -> bool {
373
+ system_path_to_file ( resolver. db . upcast ( ) , path. join ( "__init__.py" ) ) . is_some ( )
374
+ || system_path_to_file ( resolver. db . upcast ( ) , path. join ( "__init__.py" ) ) . is_some ( )
376
375
}
377
376
378
377
match ( self , search_path) {
@@ -387,8 +386,13 @@ impl<'a> ModuleResolutionPathRefInner<'a> {
387
386
match Self :: query_stdlib_version ( path, search_path, & stdlib_root, resolver) {
388
387
TypeshedVersionsQueryResult :: DoesNotExist => false ,
389
388
TypeshedVersionsQueryResult :: Exists | TypeshedVersionsQueryResult :: MaybeExists => match path {
390
- FilePathRef :: System ( path) => resolver. db . system ( ) . path_exists ( & path. join ( "__init__.pyi" ) ) ,
391
- FilePathRef :: Vendored ( path) => resolver. db . vendored ( ) . exists ( path. join ( "__init__.pyi" ) ) ,
389
+ FilePathRef :: System ( path) => system_path_to_file ( resolver. db . upcast ( ) , path. join ( "__init__.pyi" ) ) . is_some ( ) ,
390
+ // No need to use `vendored_path_to_file` here:
391
+ // (1) The vendored filesystem is immutable, so we don't need to worry about Salsa invalidation
392
+ // (2) The caching Salsa provides probably won't speed us up that much
393
+ // (TODO: check that assumption when we're able to run red-knot on larger code bases)
394
+ // (3) We don't need the `File` object that `vendored_path_to_file` would return; we just need to know if the file exists
395
+ FilePathRef :: Vendored ( path) => resolver. db . vendored ( ) . exists ( path. join ( "__init__.pyi" ) )
392
396
} ,
393
397
}
394
398
}
0 commit comments