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.
pull/169/head
Daniel Hahler 12 years ago
parent a99183bf8b
commit 0547e23411

@ -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:

Loading…
Cancel
Save