From 543704f0f54cbb1de78754ad8a323c482ab6829c Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 14 Dec 2024 12:29:29 -0800 Subject: Loop style nits --- src/application.lisp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/application.lisp') diff --git a/src/application.lisp b/src/application.lisp index f33bb9f..8c86fad 100644 --- a/src/application.lisp +++ b/src/application.lisp @@ -88,27 +88,33 @@ focus-table blur-table perframe-table)) (defmethod cleanup ((app application)) - (loop for asset being the hash-value of (application-assets app) - do (cleanup asset)) + ;; run cleanup on assets + (loop :for asset :being :the :hash-value :of (application-assets app) + :do (cleanup asset)) + ;; drop all current handlers (let ((listener (listener app))) (dolist (table +listener-table-slot-names+) (setf (slot-value listener table) (make-hash-table :synchronized t)))) - (loop for unit across (application-scene app) - do - (drop-unit unit) - (cleanup unit)) + + ;; then cleanup units + (loop :for unit :across (application-scene app) :do + (drop-unit unit) + (cleanup unit)) + + ;; finally run the exit hooks (pre-exit-hooks)) (defun run-perframe (app) "Runs all of the handlers objects listening for perframe events if they are in the scene." (let ((table (perframe-table (listener app))) (time (sdl2:get-ticks))) - (loop for target being the hash-key of table - for handlers = (slot-value (listener target) 'perframe) + (loop :for target :being :the :hash-key :of table + :for handlers := (slot-value (listener target) 'perframe) ;; only fire perframe when target is in scene - when (or (eq app target) (unit-in-scene-p target)) - do (loop for handler in handlers do (funcall handler target time))))) + :when (or (eq app target) (unit-in-scene-p target)) + :do (loop :for handler :in handlers + :do (funcall handler target time))))) (defmethod render ((app application)) (run-perframe app) @@ -119,7 +125,7 @@ (gl:blend-func :src-alpha :one-minus-src-alpha ) (with-slots (scene) app (when (plusp (length scene)) - (loop for unit across scene do (render unit)))) + (loop :for unit :across scene :do (render unit)))) (sdl2:gl-swap-window (application-window app)) (sleep (frame-wait app))) -- cgit v1.2.3