1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-17 17:08:39 +00:00

Value copy / allocation optimizations mostly in server, SAO and serialize code

This commit is contained in:
sfan5 2020-05-26 17:38:31 +02:00
parent 2fd5f38c45
commit 471e567657
16 changed files with 52 additions and 64 deletions

View file

@ -119,8 +119,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
m_properties_sent = true;
std::string str = getPropertyPacket();
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom);
m_messages_out.emplace(getId(), true, str);
}
// If attached, check that our parent is still there. If it isn't, detach.
@ -228,16 +227,14 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
m_animation_sent = true;
std::string str = generateUpdateAnimationCommand();
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom);
m_messages_out.emplace(getId(), true, str);
}
if (!m_animation_speed_sent) {
m_animation_speed_sent = true;
std::string str = generateUpdateAnimationSpeedCommand();
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom);
m_messages_out.emplace(getId(), true, str);
}
if (!m_bone_position_sent) {
@ -247,8 +244,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
std::string str = generateUpdateBonePositionCommand((*ii).first,
(*ii).second.X, (*ii).second.Y);
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom);
m_messages_out.emplace(getId(), true, str);
}
}
@ -256,8 +252,7 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
m_attachment_sent = true;
std::string str = generateUpdateAttachmentCommand();
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom);
m_messages_out.emplace(getId(), true, str);
}
}

View file

@ -223,8 +223,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
m_properties_sent = true;
std::string str = getPropertyPacket();
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom);
m_messages_out.emplace(getId(), true, str);
m_env->getScriptIface()->player_event(this, "properties_changed");
}
@ -324,10 +323,8 @@ void PlayerSAO::step(float dtime, bool send_recommended)
if (!m_attachment_sent) {
m_attachment_sent = true;
std::string str = generateUpdateAttachmentCommand();
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom);
m_messages_out.emplace(getId(), true, generateUpdateAttachmentCommand());
}
}

View file

@ -75,7 +75,7 @@ std::string ServerActiveObject::generateUpdateNametagAttributesCommand(const vid
void ServerActiveObject::dumpAOMessagesToQueue(std::queue<ActiveObjectMessage> &queue)
{
while (!m_messages_out.empty()) {
queue.push(m_messages_out.front());
queue.push(std::move(m_messages_out.front()));
m_messages_out.pop();
}
}

View file

@ -57,4 +57,4 @@ private:
ServerEnvironment *m_env = nullptr;
std::unordered_map<std::string, DetachedInventory> m_detached_inventories;
};
};