From 517c1856881d86f4b789ac2c37da6bac83994bcf Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 17 Dec 2022 22:58:56 +0000 Subject: [PATCH] Avoid recalculating operation names repeatedly. (#1) Reviewed-on: https://git.chromaticdragon.app/pyrex/chameleonic/pulls/1 Co-authored-by: Kistaro Windrider Co-committed-by: Kistaro Windrider --- chameleonic.p8 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index d99a15d..3733115 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -12,11 +12,21 @@ function _update() function _draw() _doall("draw") end +mnames={} +function names(root) + local n=mnames[root] + if(n)return all(n) + n={root.."0", root, root.."2", root.."3"} + mnames[root]=n + return all(n) +end + function _doall(x) - for x2 in all(split"0,,2,3") do + + for n in names(x) do for mod in all(modules) do - local f=mod[x..x2] - if (f != nil) f(mod) + local f=mod[n] + if (f) f(mod) end end end