diff --git a/collects/scheme/private/sort.ss b/collects/scheme/private/sort.ss index 990e5dcf52..d70669d626 100644 --- a/collects/scheme/private/sort.ss +++ b/collects/scheme/private/sort.ss @@ -33,13 +33,13 @@ doing these checks. (define-syntax foo (syntax-rules () [(_ . pattern) template]))])) (define-syntax-rule (sort-internal-body v * . 1) + (let* ([n/2+ (ceiling (/ n 2))] [n/2- (- n n/2+)]) + (let ([Amid1 (+ Alo n/2-)] + [Amid2 (+ Alo n/2+)] + [Bmid1 (+ Blo n/2-)]) + (copying-mergesort Amid1 Bmid1 n/2+) + (copying-mergesort Alo Amid2 n/2-) + (merge #t Amid2 (+ Alo n) Bmid1 (+ Blo n) Blo)))] + [(= 1 n) (set! Blo (ref Alo))])) - (let ([Alo 0] [Amid1 (- n n/2)] [Amid2 n/2] [Ahi n] - [B1lo n] [B1hi (+ n n/2)]) - (copying-mergesort Amid1 Ahi B1lo B1hi) - (copying-mergesort Alo Amid1 Amid2 Ahi) - (merge #f B1lo B1hi Amid2 Ahi Alo Ahi)))) + (let ([Alo 0] [Amid1 n/2-] [Amid2 n/2+] [Ahi n] [B1lo n]) + (copying-mergesort Amid1 B1lo n/2+) + (copying-mergesort Alo Amid2 n/2-) + (merge #f B1lo (+ B1lo n/2+) Amid2 Ahi Alo)))) (define sort-internals (make-hasheq)) (define _