summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--catbird/node.scm16
1 files changed, 14 insertions, 2 deletions
diff --git a/catbird/node.scm b/catbird/node.scm
index bc158a5..b80c45e 100644
--- a/catbird/node.scm
+++ b/catbird/node.scm
@@ -102,10 +102,16 @@
(define (for-each-child proc node)
(for-each proc (children node)))
+;; Optimized recursive update that does not allocate a closure.
+(define (update-nodes nodes dt)
+ (unless (null? nodes)
+ (update/around (car nodes) dt)
+ (update-nodes (cdr nodes) dt)))
+
(define-method (update/around (node <node>) dt)
(unless (paused? node)
;; Update children first, recursively.
- (for-each-child (lambda (child) (update/around child dt)) node)
+ (update-nodes (children node) dt)
(next-method)))
(define-method (tree-in-view? (node <node>))
@@ -114,10 +120,16 @@
(define-method (in-view? (node <node>))
#t)
+;; Optimized recursive render that does not allocate a closure.
+(define (render-nodes nodes alpha)
+ (unless (null? nodes)
+ (render/around (car nodes) alpha)
+ (render-nodes (cdr nodes) alpha)))
+
(define-method (render/around (node <node>) alpha)
(when (and (visible? node) (tree-in-view? node))
(next-method)
- (for-each-child (lambda (child) (render/around child alpha)) node)))
+ (render-nodes (children node) alpha)))
(define-method (child-ref (parent <node>) name)
(hashq-ref (children-by-name parent) name))