cs: fix inlining of unsafe vector and box operations
Before this repair, `unsafe-vector-ref` was slower than `vector-ref`.
This commit is contained in:
parent
61e39657fa
commit
77cdfde679
|
@ -635,9 +635,9 @@
|
||||||
ptr-ref/double ptr-set!/double ; not exported to Racket
|
ptr-ref/double ptr-set!/double ; not exported to Racket
|
||||||
ptr-ref/float ptr-set!/float ; not exported to Racket
|
ptr-ref/float ptr-set!/float ; not exported to Racket
|
||||||
|
|
||||||
unsafe-unbox
|
(rename [inline:unsafe-unbox unsafe-unbox]
|
||||||
|
[inline:unsafe-set-box! unsafe-set-box!])
|
||||||
unsafe-unbox*
|
unsafe-unbox*
|
||||||
unsafe-set-box!
|
|
||||||
unsafe-set-box*!
|
unsafe-set-box*!
|
||||||
unsafe-box*-cas!
|
unsafe-box*-cas!
|
||||||
|
|
||||||
|
@ -646,12 +646,12 @@
|
||||||
unsafe-set-mcar!
|
unsafe-set-mcar!
|
||||||
unsafe-set-mcdr!
|
unsafe-set-mcdr!
|
||||||
|
|
||||||
unsafe-vector-ref
|
(rename [inline:unsafe-vector-ref unsafe-vector-ref]
|
||||||
unsafe-vector-set!
|
[inline:unsafe-vector-set! unsafe-vector-set!]
|
||||||
|
[inline:unsafe-vector-length unsafe-vector-length])
|
||||||
unsafe-vector*-ref
|
unsafe-vector*-ref
|
||||||
unsafe-vector*-set!
|
unsafe-vector*-set!
|
||||||
unsafe-vector*-cas!
|
unsafe-vector*-cas!
|
||||||
unsafe-vector-length
|
|
||||||
unsafe-vector*-length
|
unsafe-vector*-length
|
||||||
|
|
||||||
unsafe-fxvector-length
|
unsafe-fxvector-length
|
||||||
|
@ -670,8 +670,8 @@
|
||||||
unsafe-string-ref
|
unsafe-string-ref
|
||||||
unsafe-string-set!
|
unsafe-string-set!
|
||||||
|
|
||||||
unsafe-struct-ref
|
(rename [inline:unsafe-struct-ref unsafe-struct-ref]
|
||||||
unsafe-struct-set!
|
[inline:unsafe-struct-set! unsafe-struct-set!])
|
||||||
unsafe-struct*-ref
|
unsafe-struct*-ref
|
||||||
unsafe-struct*-set!
|
unsafe-struct*-set!
|
||||||
unsafe-struct*-cas!
|
unsafe-struct*-cas!
|
||||||
|
|
|
@ -32,6 +32,18 @@
|
||||||
(#%$vector-set!-check? v i)
|
(#%$vector-set!-check? v i)
|
||||||
(#3%vector-set! v i n))
|
(#3%vector-set! v i n))
|
||||||
|
|
||||||
|
(define-inline (unsafe-vector-length v)
|
||||||
|
(#%vector? v)
|
||||||
|
(#3%vector-length v))
|
||||||
|
|
||||||
|
(define-inline (unsafe-vector-ref v i)
|
||||||
|
(#%vector? v)
|
||||||
|
(#3%vector-ref v i))
|
||||||
|
|
||||||
|
(define-inline (unsafe-vector-set! v i n)
|
||||||
|
(#%vector? v)
|
||||||
|
(#3%vector-set! v i n))
|
||||||
|
|
||||||
(define-inline (unbox b)
|
(define-inline (unbox b)
|
||||||
(#%box? b)
|
(#%box? b)
|
||||||
(#3%unbox b))
|
(#3%unbox b))
|
||||||
|
@ -40,6 +52,14 @@
|
||||||
(#%mutable-box? b)
|
(#%mutable-box? b)
|
||||||
(#3%set-box! b v))
|
(#3%set-box! b v))
|
||||||
|
|
||||||
|
(define-inline (unsafe-unbox b)
|
||||||
|
(#%box? b)
|
||||||
|
(#3%unbox b))
|
||||||
|
|
||||||
|
(define-inline (unsafe-set-box! b v)
|
||||||
|
(#%box? b)
|
||||||
|
(#3%set-box! b v))
|
||||||
|
|
||||||
(define-inline (mcar p)
|
(define-inline (mcar p)
|
||||||
(mpair? p)
|
(mpair? p)
|
||||||
(unsafe-mcar p))
|
(unsafe-mcar p))
|
||||||
|
@ -55,3 +75,11 @@
|
||||||
(define-inline (set-mcdr! p v)
|
(define-inline (set-mcdr! p v)
|
||||||
(mpair? p)
|
(mpair? p)
|
||||||
(unsafe-set-mcdr! p v))
|
(unsafe-set-mcdr! p v))
|
||||||
|
|
||||||
|
(define-inline (unsafe-struct-ref s i)
|
||||||
|
(not (impersonator? s))
|
||||||
|
(unsafe-struct*-ref s i))
|
||||||
|
|
||||||
|
(define-inline (unsafe-struct-set! s i v)
|
||||||
|
(not (impersonator? s))
|
||||||
|
(unsafe-struct*-set! s i v))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user