Skip to content

Commit

Permalink
Use scandir() to avoid separate is_dir() syscall (#4273)
Browse files Browse the repository at this point in the history
  • Loading branch information
dholth committed Apr 28, 2022
1 parent 3268fdd commit 4d1d522
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions conda_build/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,11 @@ def index(self, patch_generator, hotfix_source_repo=None, verbose=False, progres

with utils.LoggingContext(level, loggers=[__name__]):
if not self._subdirs:
detected_subdirs = {subdir for subdir in os.listdir(self.channel_root)
if subdir in utils.DEFAULT_SUBDIRS and isdir(join(self.channel_root, subdir))}
detected_subdirs = {
subdir.name
for subdir in os.scandir(self.channel_root)
if subdir.name in utils.DEFAULT_SUBDIRS and subdir.is_dir()
}
log.debug("found subdirs %s" % detected_subdirs)
self.subdirs = subdirs = sorted(detected_subdirs | {'noarch'})
else:
Expand Down

0 comments on commit 4d1d522

Please sign in to comment.