From a06a63e9e63c975faef54f113b32f22eab911359 Mon Sep 17 00:00:00 2001 From: Alfredo Beaumont Date: Fri, 26 Apr 2013 00:27:50 +0200 Subject: [PATCH] read-float: reduce code size a bit by using awhen instead of when --- src/read.lisp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/read.lisp b/src/read.lisp index d513ef3..43628a4 100644 --- a/src/read.lisp +++ b/src/read.lisp @@ -182,13 +182,12 @@ (incf index))) (unless (< index size) (return)) ;; Optional integer part - (let ((value (digit-char-p (char string index)))) - (when value - (setq integer-part t) - (while (and (< index size) - (setq value (digit-char-p (char string index)))) - (setq number (+ (* number 10) value)) - (incf index)))) + (awhen (digit-char-p (char string index)) + (setq integer-part t) + (while (and (< index size) + (setq it (digit-char-p (char string index)))) + (setq number (+ (* number 10) it)) + (incf index))) (unless (< index size) (return)) ;; Decimal point is mandatory if there's no integer part (unless (or integer-part (char= #\. (char string index))) (return)) @@ -196,14 +195,13 @@ (when (char= #\. (char string index)) (incf index) (unless (< index size) (return)) - (let ((value (digit-char-p (char string index)))) - (when value - (setq fractional-part t) - (while (and (< index size) - (setq value (digit-char-p (char string index)))) - (setq number (+ (* number 10) value)) - (setq divisor (* divisor 10)) - (incf index))))) + (awhen (digit-char-p (char string index)) + (setq fractional-part t) + (while (and (< index size) + (setq it (digit-char-p (char string index)))) + (setq number (+ (* number 10) it)) + (setq divisor (* divisor 10)) + (incf index)))) ;; Either left or right part of the dot must be present (unless (or integer-part fractional-part) (return)) ;; Exponent is mandatory if there is no fractional part -- 1.7.10.4