Skip to content

Commit

Permalink
Merge pull request #6696 from readthedocs/humitos/sort-in-place
Browse files Browse the repository at this point in the history
Sort vesions in-place to help performance
  • Loading branch information
humitos authored Mar 2, 2020
2 parents f11678a + a872379 commit d1fa693
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions readthedocs/projects/version_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,12 @@ def sort_versions(version_list):
if comparable_version:
versions.append((version_obj, comparable_version))

return list(
sorted(
versions,
key=lambda version_info: version_info[1],
reverse=True,
),
# sort in-place to avoid leaking memory on projects with lot of versions
versions.sort(
key=lambda version_info: version_info[1],
reverse=True,
)
return versions


def highest_version(version_list):
Expand Down

0 comments on commit d1fa693

Please sign in to comment.