From b1aa042289c86c64aabcb181a8feca07474e23a2 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Wed, 13 Jul 2011 11:41:32 -0400 Subject: [PATCH] Make index? faster. original commit: e5314f945e0827331d7e1dcd8320bb8d0c59132e --- collects/typed-scheme/types/numeric-predicates.rkt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/collects/typed-scheme/types/numeric-predicates.rkt b/collects/typed-scheme/types/numeric-predicates.rkt index c6accf1d..a99590fe 100644 --- a/collects/typed-scheme/types/numeric-predicates.rkt +++ b/collects/typed-scheme/types/numeric-predicates.rkt @@ -1,6 +1,6 @@ #lang racket/base -(require unstable/function) +(require unstable/function racket/unsafe/ops) (provide index? exact-rational?) @@ -9,6 +9,7 @@ ;; we assume indexes are 2 bits shorter than fixnums ;; We're generating a reference to fixnum? rather than calling it, so ;; we're safe from fixnum size issues on different platforms. -(define (index? x) (and (fixnum? x) (>= x 0) (fixnum? (* x 4)))) +(define (index? x) + (and (fixnum? x) (unsafe-fx>= x 0) (fixnum? (unsafe-fx* x 4)))) (define exact-rational? (conjoin rational? exact?))