random: encourage inlining.
Reduces overhead to 6% over #%kernel's for the integer case.
This commit is contained in:
parent
740b6dc198
commit
47f06f11e1
|
@ -17,6 +17,7 @@
|
||||||
"member.rkt"
|
"member.rkt"
|
||||||
"kernstruct.rkt"
|
"kernstruct.rkt"
|
||||||
"norm-arity.rkt"
|
"norm-arity.rkt"
|
||||||
|
"performance-hint.rkt"
|
||||||
"top-int.rkt"
|
"top-int.rkt"
|
||||||
'#%builtin ; so it's attached
|
'#%builtin ; so it's attached
|
||||||
(for-syntax "kw.rkt"
|
(for-syntax "kw.rkt"
|
||||||
|
@ -109,6 +110,7 @@
|
||||||
'random
|
'random
|
||||||
(string-append "integer greater than " (number->string x))
|
(string-append "integer greater than " (number->string x))
|
||||||
y))))
|
y))))
|
||||||
|
(begin-encourage-inline
|
||||||
(define-values (-random) ; more featureful than #%kernel's `random`
|
(define-values (-random) ; more featureful than #%kernel's `random`
|
||||||
(case-lambda
|
(case-lambda
|
||||||
[() (random)] ; no args, random float
|
[() (random)] ; no args, random float
|
||||||
|
@ -137,7 +139,7 @@
|
||||||
(enforce-greater min max)
|
(enforce-greater min max)
|
||||||
(unless (pseudo-random-generator? prng)
|
(unless (pseudo-random-generator? prng)
|
||||||
(raise-argument-error 'random "pseudo-random-generator?" prng))
|
(raise-argument-error 'random "pseudo-random-generator?" prng))
|
||||||
(+ min (random (- max min) prng))]))
|
(+ min (random (- max min) prng))])))
|
||||||
|
|
||||||
(define-values (new:collection-path)
|
(define-values (new:collection-path)
|
||||||
(let ([collection-path (new-lambda (collection
|
(let ([collection-path (new-lambda (collection
|
||||||
|
|
Loading…
Reference in New Issue
Block a user