diff options
author | Marin Jankovski <marin@gitlab.com> | 2014-09-12 19:40:04 +0200 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2014-09-12 19:41:32 +0200 |
commit | e84861d510af63969a7ca09e4248426faf2dd345 (patch) | |
tree | a1f6a4a2ff4a15b8ea0d2e66d503f25351dfe50f /app/helpers/diff_helper.rb | |
parent | 5564fe31491a8a584b66feb6097742ec4025b8fa (diff) | |
download | gitlab-ce-e84861d510af63969a7ca09e4248426faf2dd345.tar.gz |
Remove unecesarry array operations.
Diffstat (limited to 'app/helpers/diff_helper.rb')
-rw-r--r-- | app/helpers/diff_helper.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 8332b86d485..c2ce6ed0fe4 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -36,7 +36,10 @@ module DiffHelper # Building array of lines # - # [left_type, left_line_number, left_line_content, line_code, right_line_type, right_line_number, right_line_content] + # [ + # left_type, left_line_number, left_line_content, left_line_code, + # right_line_type, right_line_number, right_line_content, right_line_code + # ] # diff_file.diff_lines.each do |line| @@ -54,23 +57,20 @@ module DiffHelper next_line = next_line.text end - line = [type, line_old, full_line, line_code, next_line_code, next_type, line_new] - if type == 'match' || type.nil? # line in the right panel is the same as in the left one - line = [type, line_old, full_line, line_code, line_code, type, line_new, full_line] + line = [type, line_old, full_line, line_code, type, line_new, full_line, line_code] lines.push(line) elsif type == 'old' if next_type == 'new' # Left side has text removed, right side has text added - line.push(next_line) + line = [type, line_old, full_line, line_code, next_type, line_new, next_line, next_line_code] lines.push(line) skip_next = true elsif next_type == 'old' || next_type.nil? # Left side has text removed, right side doesn't have any change - line.pop # remove the newline - line.push(nil) # no line number on the right panel - line.push(" ") # empty line on the right panel + # No next line code, no new line number, no new line text + line = [type, line_old, full_line, line_code, next_type, nil, " ", nil] lines.push(line) end elsif type == 'new' @@ -80,7 +80,7 @@ module DiffHelper next else # Change is only on the right side, left side has no change - line = [nil, nil, " ", line_code, line_code, type, line_new, full_line] + line = [nil, nil, " ", line_code, type, line_new, full_line, line_code] lines.push(line) end end |