Skip to content
Snippets Groups Projects
Commit e84861d5 authored by Marin Jankovski's avatar Marin Jankovski
Browse files

Remove unecesarry array operations.

parent 5564fe31
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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|
 
Loading
Loading
@@ -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'
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -6,10 +6,10 @@
- line_number_left = line[1]
- line_content_left = line[2]
- line_code = line[3]
- line_code_next = line[4]
- type_right = line[5]
- line_number_right = line[6]
- line_content_right = line[7]
- type_right = line[4]
- line_number_right = line[5]
- line_content_right = line[6]
- line_code_right = line[7]
 
%tr.line_holder.parallel
- if type_left == 'match'
Loading
Loading
@@ -22,7 +22,7 @@
 
- if type_right == 'new'
- new_line_class = 'new'
- new_line_code = line_code_next
- new_line_code = line_code_right
- else
- new_line_class = nil
- new_line_code = line_code
Loading
Loading
@@ -37,7 +37,7 @@
- else
- comments1 = line_comments[line_code]
- unless type_left.nil? && type_right.nil?
- comments2 = line_comments[line_code_next]
- comments2 = line_comments[line_code_right]
 
- if comments1.present? || comments2.present?
= render "projects/notes/diff_notes_with_reply_parallel", notes1: comments1, notes2: comments2
Loading
Loading
- note1 = notes1.present? ? notes1.first : nil
- note2 = notes2.present? ? notes2.first : nil
-# Check if line want not changed since comment was left
/- if !defined?(line) || line == note.diff_line
%tr.notes_holder
- if note1
%td.notes_line
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment