From 7b9fa86d33b1aa42e629f152c5acb43176a420d3 Mon Sep 17 00:00:00 2001 From: tiendo1011 Date: Mon, 20 Dec 2021 13:04:37 +0700 Subject: Use comment to aid reverting in case the change is problematic --- lib/diff/lcs/internals.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/diff/lcs/internals.rb b/lib/diff/lcs/internals.rb index 6e5a962..74f8909 100644 --- a/lib/diff/lcs/internals.rb +++ b/lib/diff/lcs/internals.rb @@ -71,6 +71,9 @@ class << Diff::LCS::Internals bm = b_matches[ai] k = nil bm.reverse_each do |j| + # Previously, we would update `thresh[k] = j` if `k and (thresh[k] > j) and (thresh[k - 1] < j)` + # Otherwise, we would do this. The update appears not to be necessary, so we are trying to + # simplify to: k = replace_next_larger(thresh, j) links[k] = [k.positive? ? links[k - 1] : nil, i, j] unless k.nil? end -- cgit v1.2.1