summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortiendo1011 <tiendo1011@gmail.com>2021-12-20 13:04:37 +0700
committertiendo1011 <tiendo1011@gmail.com>2021-12-20 13:04:37 +0700
commit7b9fa86d33b1aa42e629f152c5acb43176a420d3 (patch)
treeae554b9d4e8b1ace161c4c3d4282c304691da01e
parent334b12eb1b2f8671c66b416b4ce37c3c6add18be (diff)
downloaddiff-lcs-7b9fa86d33b1aa42e629f152c5acb43176a420d3.tar.gz
Use comment to aid reverting in case the change is problematic
-rw-r--r--lib/diff/lcs/internals.rb3
1 files changed, 3 insertions, 0 deletions
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