Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit cc5fe74

Browse files
committed
minor logic optimisation
1 parent f13654e commit cc5fe74

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/pathex.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ def get_image_paths(dir_path, image_extensions=image_extensions, subdirs=False,
3232
else:
3333
gen = scandir(str(dir_path))
3434

35-
for x in list(gen):
36-
if any([x.name.lower().endswith(ext) for ext in image_extensions]):
37-
result.append( x.path if not return_Path_class else Path(x.path) )
38-
return sorted(result)
35+
for x in gen:
36+
if any(x.name.lower().endswith(ext) for ext in image_extensions): # listcomp is not needed, any() can handle gencomp
37+
result.append( Path(x) if return_Path_class else x.path ) # avoid unnecessary negative condition
38+
return result # scandir should already be sorted
3939

4040
def get_image_unique_filestem_paths(dir_path, verbose_print_func=None):
4141
result = get_image_paths(dir_path)

0 commit comments

Comments
 (0)