From f86e52d3bdf34dd6d7855d6a0fa379b903668e68 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 bc39554..a9c387b 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