From f538c2e076c236b7b65ed3ec57dd1c78763b4632 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 11 Mar 2012 19:51:28 -0400 Subject: [PATCH] Fix a macro problem in "racket/private/string.rkt". `port-success-k' is used in a single place, and instead of a simple `lambda' expression it was used with (and ... (lambda ...)), which lead to duplication of code. Instead, move the question into the `regexp-loop' macro. (The compiled zo file is indeed smaller after this change.) --- collects/racket/private/string.rkt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/collects/racket/private/string.rkt b/collects/racket/private/string.rkt index 92cd48c35b..95ce08cc04 100644 --- a/collects/racket/private/string.rkt +++ b/collects/racket/private/string.rkt @@ -229,7 +229,7 @@ (let* ([mstart (caar m)] [mend (cdar m)] [0-ok? (not (= mstart mend))]) - (if port-success-k + (if (and port-success-k (input-port? string)) (port-success-k (lambda (acc new-start new-end) (loop acc new-start new-end ipre 0-ok?)) @@ -247,12 +247,11 @@ ;; port-success-k: need to shift index of rest as reading; cannot ;; do a tail call without adding another state variable to the ;; regexp loop, so this remains inefficient - (and (input-port? string) - (lambda (loop acc start end mstart mend) - (append (map (lambda (p) - (cons (+ mend (car p)) (+ mend (cdr p)))) - (loop '() 0 (and end (- end mend)))) - (cons (cons mstart mend) acc)))) + (lambda (loop acc start end mstart mend) + (append (map (lambda (p) + (cons (+ mend (car p)) (+ mend (cdr p)))) + (loop '() 0 (and end (- end mend)))) + (cons (cons mstart mend) acc))) ;; other port functions: use string case #f #f ;; flags