perf: OBJ encode: triangle lines built directly, number format lists hoisted

This commit is contained in:
4DBug committed 2026-11-01 19:28:03 -06:00
1 parent b7e96cbf34
commit f6c7857525
2 files changed
+6 -3

No files matched your search

+2 -1
View File
@@ -151,11 +151,12 @@ function Mtl.toMaterial(e: Entry, texture: (Map) -> number): Types.Material
return m
end
local NUM_FORMATS = { "%.6g", "%.9g", "%.17g" }
local function num(v: number): string
if v == math.floor(v) and math.abs(v) < 1e15 then
return string.format("%d", v)
end
for _, f in { "%.6g", "%.9g", "%.17g" } do
for _, f in NUM_FORMATS do
local s = string.format(f, v)
if tonumber(s) == v then
return s