diff options
author | tiendo1011 <tiendo1011@gmail.com> | 2021-12-20 13:25:55 +0700 |
---|---|---|
committer | tiendo1011 <tiendo1011@gmail.com> | 2021-12-22 13:39:20 +0700 |
commit | fbedcd9d1afa7af9a1df55c158dd9baa731e6b20 (patch) | |
tree | 4c50983331059e78237f164078fed3b6bd8d4cf5 | |
parent | 6d15558f727d8ea47db895e32ae9447685122cd2 (diff) | |
download | diff-lcs-fbedcd9d1afa7af9a1df55c158dd9baa731e6b20.tar.gz |
The symmetrically makes it easier to understand
-rw-r--r-- | lib/diff/lcs.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/diff/lcs.rb b/lib/diff/lcs.rb index f102bb1..f3716e1 100644 --- a/lib/diff/lcs.rb +++ b/lib/diff/lcs.rb @@ -377,14 +377,14 @@ class << Diff::LCS ai += 1 end - next unless bj < b_size - - 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_b(event) - bj += 1 + if bj < b_size + 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_b(event) + bj += 1 + end end end |