diff options
Diffstat (limited to 'Idiffer.scm')
-rw-r--r-- | Idiffer.scm | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/Idiffer.scm b/Idiffer.scm index ee36485..58373f9 100644 --- a/Idiffer.scm +++ b/Idiffer.scm @@ -83,22 +83,21 @@ (define (diff:edits A B . p-lim) (define M (car (array-dimensions A))) (define N (car (array-dimensions B))) - (set! p-lim (if (null? p-lim) -1 (car p-lim))) - (let ((fp (make-array (A:fixZ32b) (if (negative? p-lim) - (+ 3 M N) - (+ 3 (abs (- N M)) p-lim p-lim))))) - (define est (if (< N M) - (diff2editlen fp B A p-lim) - (diff2editlen fp A B p-lim))) - (and est - (let ((edits (make-array (A:fixZ32b) est)) - (CCRR (make-array (A:fixZ32b) (* 2 (+ (max M N) 1))))) - (cond ((< N M) - (diff2edits! edits fp CCRR B A) - (diff:invert-edits! edits)) - (else - (diff2edits! edits fp CCRR A B))) - edits)))) + (define est (diff:edit-length A B (if (null? p-lim) -1 (car p-lim)))) + (and est + (let ((CCRR (make-array (A:fixZ32b) (* 2 (+ (max M N) 1)))) + (edits (make-array (A:fixZ32b) est))) + (define fp (make-array (A:fixZ32b) + (+ (max (- N (quotient M 2)) + (- M (quotient N 2))) + (- est (abs (- N M))) ; 2 * p-lim + 3))) + (cond ((< N M) + (diff2edits! edits fp CCRR B A) + (diff:invert-edits! edits)) + (else + (diff2edits! edits fp CCRR A B))) + edits))) (define (diff:edit-length A B . p-lim) (define M (car (array-dimensions A))) |