From: Chris Hanson Date: Sun, 30 Apr 2017 03:28:44 +0000 (-0700) Subject: Change char-set->regexp to use string builder. X-Git-Tag: mit-scheme-pucked-9.2.12~14^2~109 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=c43ce00421e0b2688add6b89d94d2bb43313824b;p=mit-scheme.git Change char-set->regexp to use string builder. --- diff --git a/src/runtime/regexp.scm b/src/runtime/regexp.scm index 468267752..3f3cb6d1e 100644 --- a/src/runtime/regexp.scm +++ b/src/runtime/regexp.scm @@ -195,22 +195,19 @@ USA. (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