diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-12-22 14:49:56 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-12-22 20:07:15 +0300 |
commit | 771bf9527ffd5fd8fe258381593f686d5d960a42 (patch) | |
tree | e15ff12e3419aa751e3d54e6af7823a88f7be930 /lib | |
parent | 92e15071c13f65cf7250315f1a138284880b0074 (diff) |
Improve performance of DiffDiscussion#truncated_diff_lines and DiffNote#diff_line by removing expensive diff position calculation and comparison
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/diff/file.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb index d0cfe2386ca..cd490aaa291 100644 --- a/lib/gitlab/diff/file.rb +++ b/lib/gitlab/diff/file.rb @@ -61,7 +61,9 @@ module Gitlab end def line_for_position(pos) - diff_lines.find { |line| position(line) == pos } + return nil unless pos.position_type == 'text' + + diff_lines.find { |line| line.old_line == pos.old_line && line.new_line == pos.new_line } end def position_for_line_code(code) |