]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117134: Microoptimize glob() for include_hidden=True (GH-117135)
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 22 Mar 2024 18:03:48 +0000 (20:03 +0200)
committerGitHub <noreply@github.com>
Fri, 22 Mar 2024 18:03:48 +0000 (20:03 +0200)
Lib/glob.py

index 473502c67336f97995a9f56471c411bcf5c373ff..d59641195a1c4118ac71c344e1f9cedb45ab1e8b 100644 (file)
@@ -104,8 +104,8 @@ def _iglob(pathname, root_dir, dir_fd, recursive, dironly,
 
 def _glob1(dirname, pattern, dir_fd, dironly, include_hidden=False):
     names = _listdir(dirname, dir_fd, dironly)
-    if include_hidden or not _ishidden(pattern):
-        names = (x for x in names if include_hidden or not _ishidden(x))
+    if not (include_hidden or _ishidden(pattern)):
+        names = (x for x in names if not _ishidden(x))
     return fnmatch.filter(names, pattern)
 
 def _glob0(dirname, basename, dir_fd, dironly, include_hidden=False):