From 0965af6c690583ca1641e8250145e3909e671bd8 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Mon, 4 Oct 2010 15:43:36 -0600 Subject: [PATCH] Adding some unsafe ops to the match compiler --- collects/racket/match/compiler.rkt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/collects/racket/match/compiler.rkt b/collects/racket/match/compiler.rkt index 9f422e0794..c32a4e12fe 100644 --- a/collects/racket/match/compiler.rkt +++ b/collects/racket/match/compiler.rkt @@ -1,6 +1,6 @@ #lang scheme/base -(require (for-template scheme/base "runtime.rkt" scheme/stxparam) +(require (for-template scheme/base "runtime.rkt" scheme/stxparam racket/unsafe/ops) syntax/boundmap syntax/stx "patterns.rkt" @@ -60,12 +60,13 @@ #`[(pred #,x) (let ([tmps (accs #,x)] ...) body)])) (cond [(eq? 'box k) - (compile-con-pat (list #'unbox) #'box? (compose list Box-p))] + (compile-con-pat (list #'unsafe-unbox*) #'box? (compose list Box-p))] [(eq? 'pair k) - (compile-con-pat (list #'car #'cdr) #'pair? + (compile-con-pat (list #'unsafe-car #'unsafe-cdr) #'pair? (lambda (p) (list (Pair-a p) (Pair-d p))))] [(eq? 'mpair k) - (compile-con-pat (list #'mcar #'mcdr) #'mpair? + ; XXX These should be unsafe-mcar* when mpairs have chaperones + (compile-con-pat (list #'unsafe-mcar #'unsafe-mcdr) #'mpair? (lambda (p) (list (MPair-a p) (MPair-d p))))] [(eq? 'string k) (constant-pat #'string?)] [(eq? 'number k) (constant-pat #'number?)] @@ -104,10 +105,10 @@ esc)] [(n ...) ns]) #`[(#,arity) - (let ([tmps (vector-ref #,x n)] ...) + (let ([tmps (unsafe-vector*-ref #,x n)] ...) body)]))))])]) #`[(vector? #,x) - (case (vector-length #,x) + (case (unsafe-vector*-length #,x) clauses ... [else (#,esc)])])] ;; it's a structure