Commit 2c1d5d12 authored by Robert May's avatar Robert May

Reduced instantiations in loop

Lowers the number of variables instantiated when sorting a
potentially very large set of tags.
parent afcb3d3f
......@@ -1165,17 +1165,13 @@ class Repository
end
def tags_sorted_by_committed_date
tags.sort_by do |tag|
# Annotated tags can point to any object (e.g. a blob), but generally
# tags point to a commit. If we don't have a commit, then just default
# to putting the tag at the end of the list.
target = tag.dereferenced_target
# Annotated tags can point to any object (e.g. a blob), but generally
# tags point to a commit. If we don't have a commit, then just default
# to putting the tag at the end of the list.
default = Time.current
if target
target.committed_date
else
Time.current
end
tags.sort_by do |tag|
tag.dereferenced_target&.committed_date || default
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment