From 700f99039a2cc441b9690f8c5259af2496e0b034 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Fri, 3 Nov 2017 21:11:36 -0700 Subject: [PATCH] Simplify previous fix to string-trimmer. --- src/runtime/ustring.scm | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/runtime/ustring.scm b/src/runtime/ustring.scm index dd7394479..3df63120c 100644 --- a/src/runtime/ustring.scm +++ b/src/runtime/ustring.scm @@ -1963,22 +1963,24 @@ USA. (get-trimmed (if copy? substring string-slice))) (lambda (string) (let* ((end (string-length string)) - (start (if (eq? where 'trailing) - 0 - (let loop ((index 0)) - (if (and (fix:< index end) - (predicate (string-ref string index))) - (loop (fix:+ index 1)) - index)))) - (end (if (eq? where 'leading) - end - (let loop ((index end)) - (if (and (fix:> index 0) - (predicate - (string-ref string (fix:- index 1)))) - (loop (fix:- index 1)) - index))))) - (get-trimmed string (min start end) end)))))) + (start + (if (eq? where 'trailing) + 0 + (let loop ((index 0)) + (if (and (fix:< index end) + (predicate (string-ref string index))) + (loop (fix:+ index 1)) + index))))) + (get-trimmed string + start + (if (eq? where 'leading) + end + (let loop ((index end)) + (if (and (fix:> index start) + (predicate + (string-ref string (fix:- index 1)))) + (loop (fix:- index 1)) + index))))))))) (define-deferred string-trimmer-options (keyword-option-parser -- 2.25.1