From 6d5ca7308996107f6979395e8219db8930ea85f3 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 21 Feb 2017 22:33:53 -0800 Subject: [PATCH] Eliminate now-unused vector-8b->hexadecimal and hexadecimal->vector-8b. --- src/edwin/edwin.pkg | 2 -- src/edwin/string.scm | 44 +---------------------------------------- src/runtime/runtime.pkg | 4 ---- src/runtime/string.scm | 42 --------------------------------------- 4 files changed, 1 insertion(+), 91 deletions(-) diff --git a/src/edwin/edwin.pkg b/src/edwin/edwin.pkg index aba9dd98a..8c3c63855 100644 --- a/src/edwin/edwin.pkg +++ b/src/edwin/edwin.pkg @@ -163,7 +163,6 @@ USA. guarantee-substring guarantee-substring-end-index guarantee-substring-start-index - hexadecimal->vector-8b lisp-string->camel-case list->string make-string @@ -279,7 +278,6 @@ USA. substringhexadecimal vector-8b-fill! vector-8b-find-next-char vector-8b-find-next-char-ci diff --git a/src/edwin/string.scm b/src/edwin/string.scm index 61256efc1..39d3bc3cf 100644 --- a/src/edwin/string.scm +++ b/src/edwin/string.scm @@ -587,7 +587,7 @@ USA. (or (char? object) (char-set? object) (unary-procedure? object))) - + (define (random-byte-vector n #!optional state) (let ((bv (random-bytevector n state)) (s (make-vector-8b n))) @@ -595,48 +595,6 @@ USA. ((not (fix:< i n))) (vector-8b-set! s i (bytevector-u8-ref bv i))) s)) - -(define (vector-8b->hexadecimal bytes) - (define-integrable (hex-char k) - (string-ref "0123456789abcdef" (fix:and k #x0F))) - (guarantee-string bytes 'VECTOR-8B->HEXADECIMAL) - (let ((n (vector-8b-length bytes))) - (let ((s (make-string (fix:* 2 n)))) - (do ((i 0 (fix:+ i 1)) - (j 0 (fix:+ j 2))) - ((not (fix:< i n))) - (string-set! s j (hex-char (fix:lsh (vector-8b-ref bytes i) -4))) - (string-set! s (fix:+ j 1) (hex-char (vector-8b-ref bytes i)))) - s))) - -(define (hexadecimal->vector-8b string) - (guarantee-string string 'HEXADECIMAL->VECTOR-8B) - (let ((end (string-length string)) - (lose - (lambda () - (error:bad-range-argument string 'HEXADECIMAL->VECTOR-8B)))) - (define-integrable (hex-digit char) - (let ((i (char->integer char)) - (d0 (char->integer #\0)) - (d9 (char->integer #\9)) - (la (char->integer #\a)) - (lf (char->integer #\f)) - (UA (char->integer #\A)) - (UF (char->integer #\F))) - (cond ((and (fix:<= d0 i) (fix:<= i d9)) (fix:- i d0)) - ((and (fix:<= la i) (fix:<= i lf)) (fix:+ #xa (fix:- i la))) - ((and (fix:<= UA i) (fix:<= i UF)) (fix:+ #xA (fix:- i UA))) - (else (lose))))) - (if (not (fix:= (fix:and end 1) 0)) - (lose)) - (let ((bytes (make-vector-8b (fix:lsh end -1)))) - (do ((i 0 (fix:+ i 2)) - (j 0 (fix:+ j 1))) - ((not (fix:< i end))) - (vector-8b-set! bytes j - (fix:+ (fix:lsh (hex-digit (string-ref string i)) 4) - (hex-digit (string-ref string (fix:+ i 1)))))) - bytes))) ;;;; Case diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 8cd24ea5f..cb85fb385 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -1007,10 +1007,8 @@ USA. error:not-string guarantee-string guarantee-string-index - hexadecimal->vector-8b make-legacy-string make-vector-8b - vector-8b->hexadecimal vector-8b-fill! vector-8b-find-next-char vector-8b-find-next-char-ci @@ -1025,10 +1023,8 @@ USA. error:not-string guarantee-string guarantee-string-index - hexadecimal->vector-8b make-legacy-string make-vector-8b - vector-8b->hexadecimal vector-8b-fill! vector-8b-find-next-char vector-8b-find-next-char-ci diff --git a/src/runtime/string.scm b/src/runtime/string.scm index 55d705c41..4414d6c6e 100644 --- a/src/runtime/string.scm +++ b/src/runtime/string.scm @@ -89,48 +89,6 @@ USA. (string-set! result j (string-ref string i))) result))) -(define (vector-8b->hexadecimal bytes) - (define-integrable (hex-char k) - (string-ref "0123456789abcdef" (fix:and k #x0F))) - (guarantee-string bytes 'VECTOR-8B->HEXADECIMAL) - (let ((n (vector-8b-length bytes))) - (let ((s (make-legacy-string (fix:* 2 n)))) - (do ((i 0 (fix:+ i 1)) - (j 0 (fix:+ j 2))) - ((not (fix:< i n))) - (string-set! s j (hex-char (fix:lsh (vector-8b-ref bytes i) -4))) - (string-set! s (fix:+ j 1) (hex-char (vector-8b-ref bytes i)))) - s))) - -(define (hexadecimal->vector-8b string) - (guarantee-string string 'HEXADECIMAL->VECTOR-8B) - (let ((end (string-length string)) - (lose - (lambda () - (error:bad-range-argument string 'HEXADECIMAL->VECTOR-8B)))) - (define-integrable (hex-digit char) - (let ((i (char->integer char)) - (d0 (char->integer #\0)) - (d9 (char->integer #\9)) - (la (char->integer #\a)) - (lf (char->integer #\f)) - (UA (char->integer #\A)) - (UF (char->integer #\F))) - (cond ((and (fix:<= d0 i) (fix:<= i d9)) (fix:- i d0)) - ((and (fix:<= la i) (fix:<= i lf)) (fix:+ #xa (fix:- i la))) - ((and (fix:<= UA i) (fix:<= i UF)) (fix:+ #xA (fix:- i UA))) - (else (lose))))) - (if (not (fix:= (fix:and end 1) 0)) - (lose)) - (let ((bytes (make-vector-8b (fix:lsh end -1)))) - (do ((i 0 (fix:+ i 2)) - (j 0 (fix:+ j 1))) - ((not (fix:< i end))) - (vector-8b-set! bytes j - (fix:+ (fix:lsh (hex-digit (string-ref string i)) 4) - (hex-digit (string-ref string (fix:+ i 1)))))) - bytes))) - ;;;; Case (define (string-capitalized? string) -- 2.25.1