vector-8b-find-previous-char-ci
(vector-8b-ref 2)
(vector-8b-set! 3))
-\f
+
;;;; Basic Operations
(define (make-legacy-string k #!optional char)
(if (default-object? ascii)
ascii
(integer->char ascii))))
-
-(define (reverse-string string)
- (guarantee-string string 'REVERSE-STRING)
- (%reverse-substring string 0 (string-length string)))
-
-(define (reverse-substring string start end)
- (guarantee-substring string start end 'REVERSE-SUBSTRING)
- (%reverse-substring string start end))
-
-(define (%reverse-substring string start end)
- (let ((n (fix:- end start)))
- (let ((result (make-legacy-string n)))
- (do ((i start (fix:+ i 1))
- (j (fix:- n 1) (fix:- j 1)))
- ((fix:= i end))
- (string-set! result j (string-ref string i)))
- result)))
\f
;;;; Trim
(define (%bm-substring-search-backward text tstart tend pattern pstart pend)
(let ((m (fix:- pend pstart))
(pend-1 (fix:- pend 1))
- (rpattern (reverse-substring pattern pstart pend)))
+ (rpattern (reverse-string (string-slice pattern pstart pend))))
(let ((tstart+m (fix:+ tstart m))
(lambda* (compute-last-occurrence-function rpattern 0 m))
(gamma
(define (compute-good-suffix-function pattern pstart pend gamma0)
(let ((m (fix:- pend pstart)))
(let ((pi
- (compute-prefix-function (reverse-substring pattern pstart pend)
- 0 m))
+ (compute-prefix-function
+ (reverse-string (string-slice pattern pstart pend))
+ 0 m))
(gamma (make-vector m gamma0))
(m-1 (fix:- m 1)))
(do ((l 0 (fix:+ l 1)))
(define (burst-string string delimiter allow-runs?)
((string-splitter delimiter allow-runs?) string))
-
+\f
(define (string-replace string char1 char2)
(guarantee bitless-char? char1 'string-replace)
(guarantee bitless-char? char2 'string-replace)
(string-map (lambda (char)
(if (char=? char char1) char2 char))
string))
+
+(define (reverse-string string)
+ (let ((builder (string-builder)))
+ (do ((i (fix:- (string-length string) 1)
+ (fix:- i 1)))
+ ((not (fix:>= i 0)))
+ (builder (string-ref string i)))
+ (builder)))
\f
(define (string-8-bit? string)
(receive (string start end) (translate-slice string 0 (string-length string))