Simplify previous fix to string-trimmer.
authorChris Hanson <org/chris-hanson/cph>
Sat, 4 Nov 2017 04:11:36 +0000 (21:11 -0700)
committerChris Hanson <org/chris-hanson/cph>
Sat, 4 Nov 2017 04:11:36 +0000 (21:11 -0700)
src/runtime/ustring.scm

index dd7394479255255cfaf7a1b1a733cd1d8c5b90a8..3df63120c84c871cc32edc7997fb442186ae6af8 100644 (file)
@@ -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