mirror of
https://gitlab.com/luk3yx/minetest-flow.git
synced 2025-06-20 17:18:02 +02:00
Minor performance improvement
It turns out that formspec_ast.find is quite slow, moving the field_close_on_enter code to the new shorthand elements insertion improves performance (at least on my rudimentary benchmarks of the example form) and probably negates the overhead added by the inline styles/tooltips code.
This commit is contained in:
parent
b42a9dc1be
commit
45363ee461
14
init.lua
14
init.lua
@ -572,14 +572,6 @@ local function render_ast(node, embedded)
|
||||
node.bg_fullscreen = nil
|
||||
end
|
||||
|
||||
for field in formspec_ast.find(node, 'field') do
|
||||
res[#res + 1] = {
|
||||
type = 'field_close_on_enter',
|
||||
name = field.name,
|
||||
close_on_enter = false,
|
||||
}
|
||||
end
|
||||
|
||||
-- Add the root element's background image as a fullscreen one
|
||||
if node.bgimg and not embedded then
|
||||
res[#res + 1] = {
|
||||
@ -998,6 +990,12 @@ local function insert_shorthand_elements(tree)
|
||||
|
||||
if node.type == "container" or node.type == "scroll_container" then
|
||||
insert_shorthand_elements(node)
|
||||
elseif node.type == "field" then
|
||||
table.insert(tree, i, {
|
||||
type = 'field_close_on_enter',
|
||||
name = field.name,
|
||||
close_on_enter = false,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user