From a02384b53931a30bc13150131a23af4ecf088cea Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 30 Aug 2015 10:58:38 +0100 Subject: [PATCH] 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. --- src/parser/scanner-charbuf-impl.lisp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 -------------------------------------------------- -- 2.11.0