From b7ce1fe85edb2f374bb86f8c9d503de4315d81bf Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 1 Jan 2023 13:18:31 -0800 Subject: [PATCH] tostring golf this could be golfed further by rewriting the str..= line in terms of fmt, but the performance impact of inserting the extra `fmt` calls and parsing into the tostring recursion seems likely to be a problem. --- chameleonic.p8 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index f93f63f..2398aae 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -279,14 +279,12 @@ function kbd:release(i) end function tostring(any) - if type(any)=="table" then - local str = "{ " - for k,v in pairs(any) do - str=str..tostring(k).."->"..tostring(v).." " - end - return str.."}" + if (type(any)!="table") return tostr(any) + local str = "{ " + for k,v in pairs(any) do + str..=tostring(k).."->"..tostring(v).." " end - return tostr(any) + return str.."}" end -->8