Skip to content

Commit

Permalink
improve result aggregation performance
Browse files Browse the repository at this point in the history
Using a list comprehension is faster than an explicit for loop
  • Loading branch information
jdowner committed May 19, 2016
1 parent 4ea203b commit 7ad13f5
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions autoload/pymatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ def path_score(line):
else:
res = [(path_score(line), line) for line in items]

#rez.extend([line for score, line in heapq.nlargest(limit, res)])
for score, line in heapq.nlargest(limit, res):
if score != 0:
rez.extend([line])
rez.extend([line for score, line in heapq.nlargest(limit, res) if score != 0])

# Use double quoted vim strings and escape \
vimrez = ['"' + line.replace('\\', '\\\\').replace('"', '\\"') + '"' for line in rez]
Expand Down

0 comments on commit 7ad13f5

Please sign in to comment.