From cc5fe74d6b03c5979bd37afe202ec5f0b6860edc Mon Sep 17 00:00:00 2001 From: mightbesimon <60593422+mightbesimon@users.noreply.github.com> Date: Sun, 25 Jun 2023 04:47:20 +1200 Subject: [PATCH] minor logic optimisation --- core/pathex.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/pathex.py b/core/pathex.py index 709b763..d9c6de6 100644 --- a/core/pathex.py +++ b/core/pathex.py @@ -32,10 +32,10 @@ def get_image_paths(dir_path, image_extensions=image_extensions, subdirs=False, else: gen = scandir(str(dir_path)) - for x in list(gen): - if any([x.name.lower().endswith(ext) for ext in image_extensions]): - result.append( x.path if not return_Path_class else Path(x.path) ) - return sorted(result) + for x in gen: + if any(x.name.lower().endswith(ext) for ext in image_extensions): # listcomp is not needed, any() can handle gencomp + result.append( Path(x) if return_Path_class else x.path ) # avoid unnecessary negative condition + return result # scandir should already be sorted def get_image_unique_filestem_paths(dir_path, verbose_print_func=None): result = get_image_paths(dir_path)