Optimizing conditionals

This commit is contained in:
Amy Grinn 2024-12-17 12:39:19 -05:00
parent 6aed092c24
commit 0e5fc5a73b
No known key found for this signature in database
GPG key ID: 6B558BED1DCF3192

View file

@ -748,7 +748,7 @@
(let row ((r r-start) (let row ((r r-start)
(y (- (vec2-y center) (* tile-height (floor (/ height 2)))))) (y (- (vec2-y center) (* tile-height (floor (/ height 2))))))
;; Draw menu background ;; Draw menu background
(if (= r r-start) (when (= r r-start)
(let* ((x (- (vec2-x center) (* tile-width (floor (/ width 2))))) (let* ((x (- (vec2-x center) (* tile-width (floor (/ width 2)))))
(w (* tile-width width)) (w (* tile-width width))
(h (* tile-height height))) (h (* tile-height height)))
@ -764,12 +764,11 @@
(if (= r r-start) (if (= r r-start)
(fill-text context (menu-name (current-menu)) (vec2-x center) (+ y text-offset-y)) (fill-text context (menu-name (current-menu)) (vec2-x center) (+ y text-offset-y))
(if (and (>= r -1) (< r-index num-items) (< r r-end)) (if (and (>= r -1) (< r-index num-items) (< r r-end))
(let* ((item (cond (let* ((item (if (= r -1)
((= r -1) (if (= (current-menu-page) 0)
(if (= (current-menu-page) 0) "Back" "...")) "Back" "...")
((and (= r (1- r-end)) (< r-index (1- num-items))) (if (and (= r (1- r-end)) (< r-index (1- num-items)))
"...") "..."
(else
(menu-item-name (vector-ref (menu-items (current-menu)) r-index))))) (menu-item-name (vector-ref (menu-items (current-menu)) r-index)))))
(text (string-append (if (= r-index (current-menu-index)) "▸ " " ") item))) (text (string-append (if (= r-index (current-menu-index)) "▸ " " ") item)))
(fill-text context text (vec2-x center) (+ y text-offset-y)))))) (fill-text context text (vec2-x center) (+ y text-offset-y))))))