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.
This commit is contained in:
Kistaro Windrider 2023-01-01 13:18:31 -08:00
parent 179ee35985
commit b7ce1fe85e
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -279,15 +279,13 @@ function kbd:release(i)
end
function tostring(any)
if type(any)=="table" then
if (type(any)!="table") return tostr(any)
local str = "{ "
for k,v in pairs(any) do
str=str..tostring(k).."->"..tostring(v).." "
str..=tostring(k).."->"..tostring(v).." "
end
return str.."}"
end
return tostr(any)
end
-->8
-- title screen