(loop (cdr ranges)
(fix:+ n (if (pair? (car ranges)) 3 1)))
n))))
- (let ((s (make-legacy-string n)))
- (string-set! s 0 #\[)
- (let loop ((ranges ranges) (i 1))
+ (let ((builder (string-builder)))
+ (builder #\[)
+ (let loop ((ranges ranges))
(if (pair? ranges)
- (loop (cdr ranges)
- (let ((range (car ranges)))
- (if (pair? range)
- (begin
- (string-set! s i (car range))
- (string-set! s (fix:+ i 1) #\-)
- (string-set! s (fix:+ i 2) (cdr range))
- (fix:+ i 3))
- (begin
- (string-set! s i range)
- (fix:+ i 1)))))
- (string-set! s i #\])))
- s)))
+ (let ((range (car ranges)))
+ (if (pair? range)
+ (begin
+ (builder (car range))
+ (builder #\-)
+ (builder (cdr range)))
+ (builder range)))
+ (loop (cdr ranges))))
+ (builder #\])
+ (builder))))
(re-quote-string (string (car chars))))
"")))
\ No newline at end of file