Skip to content

Commit

Permalink
Apply some performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
tiendo1011 committed Dec 22, 2021
1 parent fbedcd9 commit 47ad358
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/diff/lcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,18 @@ def traverse_sequences(seq1, seq2, callbacks = Diff::LCS::SequenceCallbacks) #:y
ai = bj = 0

matches.each do |b_line|
ax = string ? seq1[ai, 1] : seq1[ai]
bx = string ? seq2[bj, 1] : seq2[bj]

if b_line.nil?
unless ax.nil? or (string and ax.empty?)
unless seq1[ai].nil?
ax = string ? seq1[ai, 1] : seq1[ai]
bx = string ? seq2[bj, 1] : seq2[bj]

event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx)
event = yield event if block_given?
callbacks.discard_a(event)
end
else
ax = string ? seq1[ai, 1] : seq1[ai]

loop do
break unless bj < b_line

Expand Down

0 comments on commit 47ad358

Please sign in to comment.