From 0b6ae05e9b50fb8573f8226ec903a2c72a2a773f Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Mon, 23 Nov 2009 18:51:03 +0000 Subject: [PATCH] Use unsafe operations for dealing with the vectors and indexes. svn: r17007 --- collects/scheme/private/sort.ss | 74 ++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/collects/scheme/private/sort.ss b/collects/scheme/private/sort.ss index 9c6a321cda..68a7e2fa4f 100644 --- a/collects/scheme/private/sort.ss +++ b/collects/scheme/private/sort.ss @@ -24,6 +24,14 @@ doing these checks. |# +(#%require (rename '#%unsafe i+ unsafe-fx+) + (rename '#%unsafe i- unsafe-fx-) + (rename '#%unsafe i= unsafe-fx=) + (rename '#%unsafe i< unsafe-fx<) + (rename '#%unsafe i<= unsafe-fx<=) + (rename '#%unsafe i>> unsafe-fxrshift) + (rename '#%unsafe vref unsafe-vector-ref) + (rename '#%unsafe vset! unsafe-vector-set!)) (define sort (let () @@ -33,11 +41,11 @@ doing these checks. (define-syntax foo (syntax-rules () [(_ . pattern) template]))])) (define-syntax-rule (sort-internal-body v *> n 1)] [n/2+ (i- n n/2-)]) (define-syntax-rule ( j Blo) (> n 1)] [n/2+ (i- n n/2-)]) + (let ([Amid1 (i+ Alo n/2-)] + [Amid2 (i+ Alo n/2+)] + [Bmid1 (i+ Blo n/2-)]) (copying-mergesort Amid1 Bmid1 n/2+) (copying-mergesort Alo Amid2 n/2-) - (merge #t Amid2 (+ Alo n) Bmid1 (+ Blo n) Blo)))])) + (merge #t Amid2 (i+ Alo n) Bmid1 (i+ Blo n) Blo)))])) (let ([Alo 0] [Amid1 n/2-] [Amid2 n/2+] [Ahi n] [B1lo n]) (copying-mergesort Amid1 B1lo n/2+) (unless (zero? n/2-) (copying-mergesort Alo Amid2 n/2-)) - (merge #f B1lo (+ B1lo n/2+) Amid2 Ahi Alo)))) + (merge #f B1lo (i+ B1lo n/2+) Amid2 Ahi Alo)))) (define sort-internals (make-hasheq)) (define _ @@ -102,16 +110,16 @@ doing these checks. (precomp string-ci