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:
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user