From: Taylor R Campbell Date: Wed, 2 Jan 2019 02:16:36 +0000 (+0000) Subject: Integrate string operations for order of magnitude speedup. X-Git-Tag: mit-scheme-pucked-10.1.9~3^2~42 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=54463e767a2c6c365878d227d7bf07bf1888a4ba;p=mit-scheme.git Integrate string operations for order of magnitude speedup. --- diff --git a/src/edwin/string.scm b/src/edwin/string.scm index bc9543792..8fa590194 100644 --- a/src/edwin/string.scm +++ b/src/edwin/string.scm @@ -62,6 +62,7 @@ USA. (define byte0-index (fix:* 2 (bytes-per-object))) +(declare (integrate-operator string?)) (define (string? object) (or (object-type? (ucode-type string) object) (bytevector? object) @@ -75,12 +76,13 @@ USA. (define-integrable (%string-length string) (primitive-datum-ref string 1)) -(define (string-ref string index) +(define-integrable (string-ref string index) (integer->char (vector-8b-ref string index))) -(define (string-set! string index char) +(define-integrable (string-set! string index char) (vector-8b-set! string index (char->integer char))) +(declare (integrate-operator vector-8b-ref)) (define (vector-8b-ref string index) (if (not (string? string)) (error:not-a string? string 'vector-8b-ref)) @@ -90,6 +92,7 @@ USA. (error:bad-range-argument index 'vector-8b-ref)) (primitive-byte-ref string (fix:+ byte0-index index))) +(declare (integrate-operator vector-8b-set!)) (define (vector-8b-set! string index u8) (if (not (string? string)) (error:not-a string? string 'vector-8b-set!)) @@ -97,7 +100,7 @@ USA. (error:not-a index-fixnum? index 'vector-8b-set!)) (if (not (fix:< index (%string-length string))) (error:bad-range-argument index 'vector-8b-set!)) - (if (not (u8? u8)) + (if (not (and (index-fixnum? u8) (fix:<= u8 #xff))) (error:not-a u8? u8 'vector-8b-set!)) (primitive-byte-set! string (fix:+ byte0-index index) u8))