Added inline hint around `index?' definition; my own timing suggests 2x speedup
This commit is contained in:
parent
77655f9ade
commit
419b59e88e
|
@ -1,14 +1,19 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require racket/unsafe/ops)
|
(require racket/unsafe/ops
|
||||||
|
racket/performance-hint)
|
||||||
|
|
||||||
(provide index? exact-rational?)
|
(provide index? exact-rational?)
|
||||||
|
|
||||||
;; this is required for template in numeric-tower.rkt
|
;; this is required for template in numeric-tower.rkt
|
||||||
|
|
||||||
|
(begin-encourage-inline
|
||||||
|
|
||||||
;; we assume indexes are 2 bits shorter than fixnums
|
;; we assume indexes are 2 bits shorter than fixnums
|
||||||
;; We're generating a reference to fixnum? rather than calling it, so
|
;; We're generating a reference to fixnum? rather than calling it, so
|
||||||
;; we're safe from fixnum size issues on different platforms.
|
;; we're safe from fixnum size issues on different platforms.
|
||||||
(define (index? x) (and (fixnum? x) (unsafe-fx>= x 0) (fixnum? (* x 4))))
|
(define (index? x) (and (fixnum? x) (unsafe-fx>= x 0) (fixnum? (* x 4))))
|
||||||
|
|
||||||
(define (exact-rational? x) (and (rational? x) (exact? x)))
|
(define (exact-rational? x) (and (rational? x) (exact? x)))
|
||||||
|
|
||||||
|
) ; begin-encourage-inline
|
||||||
|
|
Loading…
Reference in New Issue
Block a user