Skip to content

Commit

Permalink
Avoid temporary formatting before pretty printing vector results.
Browse files Browse the repository at this point in the history
  • Loading branch information
m00natic committed Sep 13, 2018
1 parent b7bc9a4 commit 8a5d198
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,13 @@ LINE-VAR in this case is treated as the byte buffer."

(defun gen-print-select-results (res-var field-count)
"Pretty print list of results."
`(loop for i fixnum from 0 below (length ,res-var)
do (let ((line (aref ,res-var i)))
(declare (type (simple-array simple-base-string (,field-count)) line))
,(let ((fmt-str (with-output-to-string (s nil :element-type 'base-char)
(loop repeat field-count
do (write-string "|~A" s))
(write-string "|~%" s))))
`(format t ,fmt-str ,@(loop for i fixnum from 0 below field-count
collect `(aref line ,i)))))))
`(loop for line across ,res-var
do (locally (declare (type (simple-array simple-base-string (,field-count)) line))
,@(loop for i fixnum from 0 below field-count
collect '(write-char #\|)
collect `(write-string (aref line ,i))))
(write-char #\|)
(terpri)))

(defgeneric gen-cnt (spec where jobs)
(:documentation "Generate count procedure for SPEC db with WHERE filter."))
Expand Down

0 comments on commit 8a5d198

Please sign in to comment.