Handle dirs only once

Time: 5.73s/5.88s => 5.36s

(Before rebase: 4.86s => 4.45s)
This commit is contained in:
Daniel Hahler 2018-10-25 17:19:19 +02:00
parent 2b50911c9d
commit 6ffa347c77
1 changed files with 11 additions and 7 deletions

View File

@ -529,16 +529,20 @@ class Session(nodes.FSCollector):
def filter_(f):
return f.check(file=1)
seen_dirs = set()
for path in argpath.visit(
fil=filter_, rec=self._recurse, bf=True, sort=True
):
pkginit = path.dirpath().join("__init__.py")
if pkginit.exists() and not any(
x in parts(pkginit.strpath) for x in paths
):
for x in root._collectfile(pkginit):
yield x
paths.append(x.fspath.dirpath())
dirpath = path.dirpath()
if dirpath not in seen_dirs:
seen_dirs.add(dirpath)
pkginit = dirpath.join("__init__.py")
if pkginit.exists() and not any(
x in parts(pkginit.strpath) for x in paths
):
for x in root._collectfile(pkginit):
yield x
paths.append(x.fspath.dirpath())
if not any(x in parts(path.strpath) for x in paths):
for x in root._collectfile(path):