engine: move tick call to helper trampoline, +10% perf increase
parent
1553bdce9b
commit
057207fc72
|
@ -32,6 +32,14 @@ sent.register = function (cfg)
|
|||
local sent_id = __sent_new(table, sent_class_id)
|
||||
table.__sent_id = sent_id
|
||||
|
||||
-- Make 'tick' trampoline, used by runtime to do fast call into ticker
|
||||
-- without bind/argument push.
|
||||
table.__sent_tick = function()
|
||||
if table.tick ~= nil then
|
||||
table:tick()
|
||||
end
|
||||
end
|
||||
|
||||
-- Configure components dispatcher.
|
||||
table.components = {}
|
||||
table.components.__sent_id = sent_id
|
||||
|
|
|
@ -503,20 +503,13 @@ where
|
|||
continue;
|
||||
}
|
||||
};
|
||||
let tick: mlua::Function = match table.get("tick") {
|
||||
let cb: mlua::Function = match table.raw_get("__sent_tick") {
|
||||
Ok(tick) => tick,
|
||||
Err(err) => {
|
||||
log::warn!("Entity {}/{} tick failed: getting tick function failed: {:?}", ecsid, sent.internal_id, err);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let cb = match tick.bind(table) {
|
||||
Ok(cb) => cb,
|
||||
Err(err) => {
|
||||
log::warn!("Entity {}/{} tick failed: could not bind: {:?}", ecsid, sent.internal_id, err);
|
||||
continue;
|
||||
},
|
||||
};
|
||||
tickers.push((*ecsid, cb));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue