From: Christophe Rhodes Date: Sun, 10 Aug 2014 07:25:59 +0000 (+0100) Subject: simplify squeeze-mixer-compute-bar a bit X-Git-Url: http://christophe.rhodes.io/gitweb/?p=squeeze-el.git;a=commitdiff_plain;h=4b96c04eadcdd37603d78a13eaa40b5b90dee07e simplify squeeze-mixer-compute-bar a bit compute a quotient rather than repeated comparisons with fractional part --- diff --git a/squeeze.el b/squeeze.el index c6f10d9..6e4f4da 100644 --- a/squeeze.el +++ b/squeeze.el @@ -144,16 +144,9 @@ (nblank (floor (- width exact)))) (format "%s%s%s" (make-string nfull ?█) - (cond ((= width (+ nfull nblank)) "") - ((< frac 0.0625) " ") - ((< frac 0.1875) "▏") - ((< frac 0.3125) "▎") - ((< frac 0.4375) "▍") - ((< frac 0.5625) "▌") - ((< frac 0.6875) "▋") - ((< frac 0.8125) "▊") - ((< frac 0.9375) "▉") - (t "█")) + (if (= width (+ nfull nblank)) + "" + (aref " ▏▎▍▌▋▊▉█" (floor (+ frac 0.0625) 0.125))) (make-string nblank ? )))) (defun squeeze-mixer-make-bar (vol width)