Commit fb075938 authored by James Fargher's avatar James Fargher

Merge branch 'further-blame-improvements' into 'master'

Reducing variable instantiations in blame processing

See merge request gitlab-org/gitlab!55973
parents f499165e 49d9f224
......@@ -19,16 +19,14 @@ module Gitlab
commit = Commit.new(commit, project)
commit.lazy_author # preload author
sha = commit.sha
if prev_sha != sha
if prev_sha != commit.sha
groups << current_group if current_group
current_group = { commit: commit, lines: [] }
end
line = highlighted_lines[i].html_safe if highlight
current_group[:lines] << line
current_group[:lines] << (highlight ? highlighted_lines[i].html_safe : line)
prev_sha = sha
prev_sha = commit.sha
i += 1
end
groups << current_group if current_group
......
......@@ -38,9 +38,11 @@ module Gitlab
if line[0, 1] == "\t"
lines << line[1, line.size]
elsif m = /^(\w{40}) (\d+) (\d+)/.match(line)
commit_id, old_lineno, lineno = m[1], m[2].to_i, m[3].to_i
# Removed these instantiations for performance but keeping them for reference:
# commit_id, old_lineno, lineno = m[1], m[2].to_i, m[3].to_i
commit_id = m[1]
commits[commit_id] = nil unless commits.key?(commit_id)
info[lineno] = [commit_id, old_lineno]
info[m[3].to_i] = [commit_id, m[2].to_i]
end
end
......@@ -50,8 +52,7 @@ module Gitlab
# get it together
info.sort.each do |lineno, (commit_id, old_lineno)|
commit = commits[commit_id]
final << BlameLine.new(lineno, old_lineno, commit, lines[lineno - 1])
final << BlameLine.new(lineno, old_lineno, commits[commit_id], lines[lineno - 1])
end
@lines = final
......
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