Skip to content

Commit 1e959c7

Browse files
committed
[[ Diff ]] Improve performance by reducing comparisons in while loop in snake function
1 parent 3d92296 commit 1e959c7

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

extensions/script-libraries/diff/diff.livecodescript

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,9 @@ private command compare_diagonal @pFP, @pPath, @pA, pALength, @pB, pBLength, k
535535
end compare_diagonal
536536

537537
private function snake @pA, pALength, @pB, pBLength, k, y
538-
local x
539-
put y - k into x
540-
repeat while (x < pALength) and (y < pBLength) and pA[x + 1] is pB[y + 1]
541-
add 1 to x
538+
local tLimit
539+
put min(pALength + k, pBLength) into tLimit
540+
repeat while (y < tLimit) and pA[y - k + 1] is pB[y + 1]
542541
add 1 to y
543542
end repeat
544543

0 commit comments

Comments
 (0)