17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-30 13:10:29 +01:00

refactor(sonar): use try_emplace for map insertion (cpp:S6030)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jerrrrycho
2026-10-10 15:51:29 +02:00
parent 6547f7e967
commit 95bc9bd511
17 changed files with 64 additions and 64 deletions

View File

@@ -799,7 +799,7 @@ void command_queue::update()
for (auto c : m_active_continuous)
{
command_data data({c.first, GLFW_REPEAT, 0.0, 0.0, delta, false, glm::vec3()}); // todo: improve
auto lookup = m_commands.emplace( c.second, commanddata_sequence() );
auto lookup = m_commands.try_emplace( c.second, commanddata_sequence() );
// recipient stack was either located or created, so we can add to it quite safely
lookup.first->second.emplace_back( data );
}
@@ -809,7 +809,7 @@ void command_queue::update()
void
command_queue::push( command_data const &Command, uint32_t const Recipient ) {
if (is_network_target(Recipient)) {
auto lookup = m_intercept_queue.emplace(Recipient, commanddata_sequence());
auto lookup = m_intercept_queue.try_emplace(Recipient, commanddata_sequence());
lookup.first->second.emplace_back(Command);
} else {
push_direct(Command, Recipient);
@@ -827,7 +827,7 @@ void command_queue::push_direct(const command_data &Command, const uint32_t Reci
return;
}
auto lookup = m_commands.emplace( Recipient, commanddata_sequence() );
auto lookup = m_commands.try_emplace( Recipient, commanddata_sequence() );
// recipient stack was either located or created, so we can add to it quite safely
lookup.first->second.emplace_back( Command );
}

View File

@@ -184,7 +184,7 @@ drivermouse_input::recall_bindings() {
std::unordered_map<std::string, user_command> nametocommandmap;
std::size_t commandid = 0;
for( auto const &description : simulation::Commands_descriptions ) {
nametocommandmap.emplace(
nametocommandmap.try_emplace(
description.name,
static_cast<user_command>( commandid ) );
++commandid;

View File

@@ -167,7 +167,7 @@ gamepad_input::recall_bindings() {
std::unordered_map<std::string, user_command> nametocommandmap;
std::size_t commandid = 0;
for( auto const &description : simulation::Commands_descriptions ) {
nametocommandmap.emplace(
nametocommandmap.try_emplace(
description.name,
static_cast<user_command>( commandid ) );
++commandid;

View File

@@ -147,7 +147,7 @@ keyboard_input::recall_bindings() {
std::unordered_map<std::string, user_command> nametocommandmap;
std::size_t commandid = 0;
for( auto const &description : simulation::Commands_descriptions ) {
nametocommandmap.emplace(
nametocommandmap.try_emplace(
description.name,
static_cast<user_command>( commandid ) );
++commandid;
@@ -155,7 +155,7 @@ keyboard_input::recall_bindings() {
std::unordered_map<std::string, int> nametokeymap;
for (const std::pair<int, std::string> &key : keytonamemap) {
nametokeymap.emplace(key.second, key.first);
nametokeymap.try_emplace(key.second, key.first);
}
// NOTE: to simplify things we expect one entry per line, and whole entry in one line