Create repeated string literals only once
@@ -652,12 +652,14 @@ function Coder:init_upvalues()
for _, v in ipairs(ir.get_srcs(cmd)) do
if v._tag == "ir.Value.String" then
local str = v.value
+ if not self.upvalue_of_string[str] then
table.insert(self.upvalues, coder.Upvalue.String(str))
self.upvalue_of_string[str] = #self.upvalues
end
end
end
end
+ end
-- Functions
for _, func in ipairs(self.module.functions) do
