Create a MyersBinaryDiff object
maximum storage limit
bail-out limit factor
source data
start of source data
length of source data
target data
start of target data
length of target data
the edit script
Copyright © 2025 DiffusionData Ltd. All Rights Reserved.
Implementation of Myer's diff with the linear space refinement.
Diff the subset of two buffers, as specified by offset/length parameters, with differences written to the provided script.
See E. Myers (1986). "An O(ND) Difference Algorithm and Its Variations". Algorithmica 1 (2): 251–266. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
For more documentation, refer to the Java implementation.
The bail out factor determines when to give up in middlesnake and produce a more approximate result. Larger values increase the precision at the cost of increased CPU.
The number of diagonals to search in each middleSnake call is bounded by max(256, bailOutFactor/100 * totalLength)
For inputs with a lot of small differences, a smaller bailOutFactor often has a beneficial effect of moderately reducing the size of the result. But it can also increase the size, occasionally dramatically. Additionally, the reduced precision affects the quality of JSON structural deltas. YMMV, as they say.