1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

Avoid calls to stat() in find_matches

Instead of stating every directory to check if its realpath is the
current directory, only do so for any potential matches.
This commit is contained in:
Daniel Hahler 2012-12-18 11:32:58 +01:00
parent a99183bf8b
commit 0547e23411

View File

@ -368,10 +368,6 @@ def find_matches(db, patterns, max_matches=1, ignore_case=False, fuzzy=False):
return []
for path, _ in dirs:
# avoid jumping to current directory
if current_dir == decode(os.path.realpath(path)) :
continue
found, tmp = True, path
for n, p in enumerate(patterns):
# for single/last pattern, only check end of path
@ -382,6 +378,11 @@ def find_matches(db, patterns, max_matches=1, ignore_case=False, fuzzy=False):
if not found: break
if found and (os.path.exists(path) or TESTING):
# avoid jumping to current directory
# (call out to realpath this late to not stat all dirs)
if current_dir == decode(os.path.realpath(path)) :
continue
if path not in results:
results.append(path)
if len(results) >= max_matches: