minimize extra dv::value copies

This commit is contained in:
MihailRis 2024-09-19 13:45:32 +03:00
parent bd176f24e1
commit 3953583605
14 changed files with 29 additions and 26 deletions

View file

@ -54,7 +54,7 @@ static int l_spawn(lua::State* L) {
if (lua::gettop(L) > 2) {
args = lua::tovalue(L, 3);
}
level->entities->spawn(def, pos, args);
level->entities->spawn(def, pos, std::move(args));
return 1;
}

View file

@ -340,8 +340,8 @@ void scripting::on_entity_spawn(
const EntityDef&,
entityid_t eid,
const std::vector<std::unique_ptr<UserComponent>>& components,
dv::value args,
dv::value saved
const dv::value& args,
const dv::value& saved
) {
auto L = lua::get_main_thread();
lua::requireglobal(L, STDCOMP);

View file

@ -94,8 +94,8 @@ namespace scripting {
const EntityDef& def,
entityid_t eid,
const std::vector<std::unique_ptr<UserComponent>>& components,
dv::value args,
dv::value saved
const dv::value& args,
const dv::value& saved
);
void on_entity_despawn(const Entity& entity);
void on_entity_grounded(const Entity& entity, float force);