From 765c4ecaccb6687cc67111e2c36229454e39f814 Mon Sep 17 00:00:00 2001 From: mehbark Date: Wed, 18 Dec 2024 14:01:36 -0500 Subject: [PATCH] bf: rePUT, 3.5x perf with mp type decl ~3.6s mandelbrot --- bf.lisp | 4 ++++ utils.lisp | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bf.lisp b/bf.lisp index 711fac1..3b6c678 100644 --- a/bf.lisp +++ b/bf.lisp @@ -54,6 +54,8 @@ `(loop until (zerop cell) do (progn ,@inner))) out)))) + ;; WE NEED TO PUT BECAUSE LOOPS IDOIT! + finally (put) finally (return (nreverse out))))) (defparameter mem-size 32768) @@ -65,6 +67,8 @@ (begin (= mem (make-array ,mem-size :element-type '(unsigned-byte 8))) (= mp 0) + (declare (type (mod ,mem-size) mp)) + (=sm cell (aref mem mp)) (=f inc (n) (incmodf cell 256 n)) diff --git a/utils.lisp b/utils.lisp index 205fcc3..fc1742d 100644 --- a/utils.lisp +++ b/utils.lisp @@ -664,6 +664,15 @@ ;; (defmacro <>-> (val &body body) ;; `(as-> ,val <> ,@body)) +;; the value of this is that (-> x car) is (car x) instead of (let1 it x (car x)), enabling setf +(defmacro -> (x &body body) + (match body + ((cons (cons f xs) rest) + `(-> (,f ,x ,@xs) ,@rest)) + ((cons f rest) + `(-> (,f ,x) ,@rest)) + (nil x))) + (defmacro doprod ((&rest binds) &body body) (if (null binds) `(progn ,@body) @@ -690,9 +699,8 @@ `(let-match1 ,pattern (progn ,@body) (begin ,@rest))) - ;; consider LABELS ((structure ('=f name args . body)) - `(flet ((,name ,args (begin ,@body))) + `(labels ((,name ,args (begin ,@body))) (begin ,@rest))) ((structure ('=m name args . body))