From: Mark Wooding Date: Sun, 30 Aug 2015 09:58:38 +0000 (+0100) Subject: src/parser/scanner-charbuf-impl.lisp: Simplify `stream-read-line'. X-Git-Url: https://git.distorted.org.uk/~mdw/sod/commitdiff_plain/a02384b53931a30bc13150131a23af4ecf088cea src/parser/scanner-charbuf-impl.lisp: Simplify `stream-read-line'. We do more or less the same stuff at the end regardless of how we got there, so factor it out. --- diff --git a/src/parser/scanner-charbuf-impl.lisp b/src/parser/scanner-charbuf-impl.lisp index 414e1a8..8377a74 100644 --- a/src/parser/scanner-charbuf-impl.lisp +++ b/src/parser/scanner-charbuf-impl.lisp @@ -433,12 +433,10 @@ (flet ((snarf (buf start end) (let ((pos (position #\newline buf :start start :end end))) (push (make-charbuf-slice buf start (or pos end)) slices) - (if pos - (values (concatenate-charbuf-slices (nreverse slices)) - (1+ pos)) - (values nil 0)))) - (fail () - (values (concatenate-charbuf-slices (nreverse slices)) t))) - (charbuf-scanner-map scanner #'snarf #'fail))))) + (values pos (and pos (1+ pos)))))) + (multiple-value-bind (result eofp) + (charbuf-scanner-map scanner #'snarf) + (declare (ignore result)) + (values (concatenate-charbuf-slices (nreverse slices))) eofp))))) ;;;----- That's all, folks --------------------------------------------------