mirror of
https://github.com/flynx/diff.js.git
synced 2025-10-29 02:50:10 +00:00
some structuring and notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c8f6173f76
commit
f95a26db75
16
diff.js
16
diff.js
@ -142,17 +142,23 @@ var getCommonSections = function(A, B, a, b, min_chunk){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get next chunks...
|
// get next chunks...
|
||||||
// XXX this repeats checks, need to optimize...
|
// XXX this repeats checks ( O(n^2) ), need to optimize...
|
||||||
var L = A.length > a+l + min_chunk ?
|
var L = A.length > a+l + min_chunk ?
|
||||||
getCommonSections(A, B, l+a+1, l+b, min_chunk)
|
getCommonSections(
|
||||||
|
A, B,
|
||||||
|
l+a+1, l+b,
|
||||||
|
min_chunk)
|
||||||
: [0]
|
: [0]
|
||||||
var R = B.length > b+l + min_chunk ?
|
var R = B.length > b+l + min_chunk ?
|
||||||
getCommonSections(A, B, l+a, l+b+1, min_chunk)
|
getCommonSections(
|
||||||
|
A, B,
|
||||||
|
l+a, l+b+1,
|
||||||
|
min_chunk)
|
||||||
: [0]
|
: [0]
|
||||||
|
|
||||||
// select the best chunk-set...
|
// select the best chunk-set...
|
||||||
// XXX need to balance the minimum number of chunks and maximum
|
// NOTE: we maximize the number of elements in a chunk set then
|
||||||
// number of elements here...
|
// minimize the number of chunks per set...
|
||||||
var next = L[0] == R[0] ?
|
var next = L[0] == R[0] ?
|
||||||
(L.length < R.length ? L : R)
|
(L.length < R.length ? L : R)
|
||||||
: L[0] > R[0] ?
|
: L[0] > R[0] ?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user