mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-19 09:39:19 +02:00
refactor(sonar): use try_emplace for map insertion (cpp:S6030)
This commit is contained in:
@@ -9762,7 +9762,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Param.", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Param", inputline);
|
||||
fizlines.try_emplace("Param", inputline);
|
||||
LoadFIZ_Param(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9770,7 +9770,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Load:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Load", inputline);
|
||||
fizlines.try_emplace("Load", inputline);
|
||||
LoadFIZ_Load(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9778,7 +9778,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Dimensions:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Dimensions", inputline);
|
||||
fizlines.try_emplace("Dimensions", inputline);
|
||||
LoadFIZ_Dimensions(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9786,7 +9786,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Wheels:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Wheels", inputline);
|
||||
fizlines.try_emplace("Wheels", inputline);
|
||||
LoadFIZ_Wheels(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9794,7 +9794,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Brake:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Brake", inputline);
|
||||
fizlines.try_emplace("Brake", inputline);
|
||||
LoadFIZ_Brake(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9803,7 +9803,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
{
|
||||
|
||||
startBPT = false;
|
||||
fizlines.emplace("Doors", inputline);
|
||||
fizlines.try_emplace("Doors", inputline);
|
||||
LoadFIZ_Doors(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9812,7 +9812,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
{
|
||||
|
||||
startBPT = false;
|
||||
fizlines.emplace("BuffCoupl", inputline);
|
||||
fizlines.try_emplace("BuffCoupl", inputline);
|
||||
LoadFIZ_BuffCoupl(inputline, 0);
|
||||
continue;
|
||||
}
|
||||
@@ -9821,7 +9821,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
{
|
||||
|
||||
startBPT = false;
|
||||
fizlines.emplace("BuffCoupl1", inputline);
|
||||
fizlines.try_emplace("BuffCoupl1", inputline);
|
||||
LoadFIZ_BuffCoupl(inputline, 1);
|
||||
continue;
|
||||
}
|
||||
@@ -9830,7 +9830,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
{
|
||||
|
||||
startBPT = false;
|
||||
fizlines.emplace("BuffCoupl2", inputline);
|
||||
fizlines.try_emplace("BuffCoupl2", inputline);
|
||||
LoadFIZ_BuffCoupl(inputline, 2);
|
||||
continue;
|
||||
}
|
||||
@@ -9839,7 +9839,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
{
|
||||
|
||||
startBPT = false;
|
||||
fizlines.emplace("TurboPos", inputline);
|
||||
fizlines.try_emplace("TurboPos", inputline);
|
||||
LoadFIZ_TurboPos(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9849,7 +9849,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
|
||||
startBPT = true;
|
||||
LISTLINE = 0;
|
||||
fizlines.emplace("Cntrl", inputline);
|
||||
fizlines.try_emplace("Cntrl", inputline);
|
||||
LoadFIZ_Cntrl(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9857,7 +9857,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Headlights:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Headlights", inputline);
|
||||
fizlines.try_emplace("Headlights", inputline);
|
||||
LoadFIZ_Headlights(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9867,7 +9867,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
|
||||
startBPT = false;
|
||||
LISTLINE = 0;
|
||||
fizlines.emplace("Blending", inputline);
|
||||
fizlines.try_emplace("Blending", inputline);
|
||||
LoadFIZ_Blending(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9877,7 +9877,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
|
||||
startBPT = false;
|
||||
LISTLINE = 0;
|
||||
fizlines.emplace("DCEMUED", inputline);
|
||||
fizlines.try_emplace("DCEMUED", inputline);
|
||||
LoadFIZ_DCEMUED(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9887,7 +9887,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
|
||||
startBPT = false;
|
||||
LISTLINE = 0;
|
||||
fizlines.emplace("SpringBrake", inputline);
|
||||
fizlines.try_emplace("SpringBrake", inputline);
|
||||
LoadFIZ_SpringBrake(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9896,7 +9896,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
{
|
||||
|
||||
startBPT = false;
|
||||
fizlines.emplace("Light", inputline);
|
||||
fizlines.try_emplace("Light", inputline);
|
||||
LoadFIZ_Light(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9904,7 +9904,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Security:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Security", inputline);
|
||||
fizlines.try_emplace("Security", inputline);
|
||||
SecuritySystem.load(inputline, Vmax);
|
||||
extract_value(EmergencyBrakeWarningSignal, "EmergencyBrakeWarningSignal", inputline, "");
|
||||
continue;
|
||||
@@ -9914,7 +9914,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
{
|
||||
|
||||
startBPT = false;
|
||||
fizlines.emplace("Clima", inputline);
|
||||
fizlines.try_emplace("Clima", inputline);
|
||||
LoadFIZ_Clima(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9922,7 +9922,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Power:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Power", inputline);
|
||||
fizlines.try_emplace("Power", inputline);
|
||||
LoadFIZ_Power(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9930,7 +9930,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("SpeedControl:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("SpeedControl", inputline);
|
||||
fizlines.try_emplace("SpeedControl", inputline);
|
||||
LoadFIZ_SpeedControl(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9938,7 +9938,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Engine:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Engine", inputline);
|
||||
fizlines.try_emplace("Engine", inputline);
|
||||
LoadFIZ_Engine(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9946,7 +9946,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Switches:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Switches", inputline);
|
||||
fizlines.try_emplace("Switches", inputline);
|
||||
LoadFIZ_Switches(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9956,7 +9956,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
startBPT = false;
|
||||
startMPT = true;
|
||||
LISTLINE = 0;
|
||||
fizlines.emplace("MotorParamTable", inputline);
|
||||
fizlines.try_emplace("MotorParamTable", inputline);
|
||||
LoadFIZ_MotorParamTable(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9972,7 +9972,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("Circuit:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("Circuit", inputline);
|
||||
fizlines.try_emplace("Circuit", inputline);
|
||||
LoadFIZ_Circuit(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9980,7 +9980,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("AI:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("AI", inputline);
|
||||
fizlines.try_emplace("AI", inputline);
|
||||
LoadFIZ_AI(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -9988,7 +9988,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("RList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("RList", inputline);
|
||||
fizlines.try_emplace("RList", inputline);
|
||||
startRLIST = true;
|
||||
LISTLINE = 0;
|
||||
LoadFIZ_RList(inputline);
|
||||
@@ -9998,7 +9998,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("UCList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("UCList", inputline);
|
||||
fizlines.try_emplace("UCList", inputline);
|
||||
startUCLIST = true;
|
||||
LISTLINE = 0;
|
||||
LoadFIZ_UCList(inputline);
|
||||
@@ -10008,7 +10008,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("DList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("DList", inputline);
|
||||
fizlines.try_emplace("DList", inputline);
|
||||
startDLIST = true;
|
||||
LISTLINE = 0;
|
||||
LoadFIZ_DList(inputline);
|
||||
@@ -10018,7 +10018,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("DMList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("DMList", inputline);
|
||||
fizlines.try_emplace("DMList", inputline);
|
||||
startDIZELMOMENTUMLIST = true;
|
||||
LISTLINE = 0;
|
||||
continue;
|
||||
@@ -10027,7 +10027,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("HTCList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("HTCList", inputline);
|
||||
fizlines.try_emplace("HTCList", inputline);
|
||||
startHYDROTCLIST = true;
|
||||
LISTLINE = 0;
|
||||
continue;
|
||||
@@ -10036,7 +10036,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("PmaxList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("PmaxList", inputline);
|
||||
fizlines.try_emplace("PmaxList", inputline);
|
||||
startPMAXLIST = true;
|
||||
LISTLINE = 0;
|
||||
continue;
|
||||
@@ -10045,7 +10045,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("V2NList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("V2NList", inputline);
|
||||
fizlines.try_emplace("V2NList", inputline);
|
||||
startDIZELV2NMAXLIST = true;
|
||||
LISTLINE = 0;
|
||||
continue;
|
||||
@@ -10081,7 +10081,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("WiperList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("WiperList", inputline);
|
||||
fizlines.try_emplace("WiperList", inputline);
|
||||
startWiperList = true;
|
||||
LISTLINE = 0;
|
||||
LoadFIZ_WiperList(inputline);
|
||||
@@ -10094,7 +10094,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
dimPositions.clear(); // uzywamy customowej listy
|
||||
startBPT = false;
|
||||
startDimmerList = true;
|
||||
fizlines.emplace("DimmerList", inputline);
|
||||
fizlines.try_emplace("DimmerList", inputline);
|
||||
LoadFIZ_DimmerList(inputline);
|
||||
continue;
|
||||
}
|
||||
@@ -10102,7 +10102,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("LightsList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("LightsList", inputline);
|
||||
fizlines.try_emplace("LightsList", inputline);
|
||||
startLIGHTSLIST = true;
|
||||
LISTLINE = 0;
|
||||
LoadFIZ_LightsList(inputline);
|
||||
@@ -10112,7 +10112,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
if (issection("CompressorList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("CompressorList", inputline);
|
||||
fizlines.try_emplace("CompressorList", inputline);
|
||||
startCOMPRESSORLIST = true;
|
||||
LISTLINE = 0;
|
||||
LoadFIZ_CompressorList(inputline);
|
||||
|
||||
@@ -228,7 +228,7 @@ void gl::shader::parse_texture_entries(std::string &str)
|
||||
else if (conf.id >= gl::MAX_TEXTURES)
|
||||
log_error("invalid texture binding: " + std::to_string(conf.id));
|
||||
else
|
||||
texture_conf.emplace(std::make_pair(name, conf));
|
||||
texture_conf.try_emplace(name, conf);
|
||||
}
|
||||
else
|
||||
log_error("invalid argument count to #texture");
|
||||
@@ -289,7 +289,7 @@ void gl::shader::parse_param_entries(std::string &str)
|
||||
else if (conf.offset + conf.size > 4)
|
||||
log_error("invalid size: " + std::to_string(conf.size));
|
||||
else
|
||||
param_conf.emplace(std::make_pair(name, conf));
|
||||
param_conf.try_emplace(name, conf);
|
||||
}
|
||||
else
|
||||
log_error("invalid argument count to #param");
|
||||
@@ -379,9 +379,9 @@ gl::program::program(std::vector<std::reference_wrapper<const gl::shader>> shade
|
||||
void gl::program::attach(const gl::shader &s)
|
||||
{
|
||||
for (auto it : s.texture_conf)
|
||||
texture_conf.emplace(std::make_pair(it.first, std::move(it.second)));
|
||||
texture_conf.try_emplace(it.first, std::move(it.second));
|
||||
for (auto it : s.param_conf)
|
||||
param_conf.emplace(std::make_pair(it.first, std::move(it.second)));
|
||||
param_conf.try_emplace(it.first, std::move(it.second));
|
||||
glAttachShader(*this, *s);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -94,7 +94,7 @@ void ui::vehicles_bank::parse_category_entry(const std::string ¶m)
|
||||
std::string mini;
|
||||
std::getline(stream, mini, ',');
|
||||
|
||||
category_icons.emplace(ctx_type, "textures/mini/" + ToLower(mini) + ".bmp");
|
||||
category_icons.try_emplace(ctx_type, "textures/mini/" + ToLower(mini) + ".bmp");
|
||||
}
|
||||
|
||||
void ui::vehicles_bank::parse_controllable_entry(const std::string &target, const std::string ¶m)
|
||||
@@ -123,7 +123,7 @@ void ui::vehicles_bank::parse_texture_info(const std::string &target, const std:
|
||||
set.meta = meta;
|
||||
|
||||
if (!mini.empty())
|
||||
group_icons.emplace(mini, std::move(deferred_image("textures/mini/" + ToLower(mini) + ".bmp")));
|
||||
group_icons.try_emplace(mini, std::move(deferred_image("textures/mini/" + ToLower(mini) + ".bmp")));
|
||||
|
||||
if (!miniplus.empty())
|
||||
set.mini = std::move(deferred_image("textures/mini/" + ToLower(miniplus) + ".bmp"));
|
||||
@@ -261,7 +261,7 @@ std::shared_ptr<ui::vehicle_desc> ui::vehicles_bank::get_vehicle(const std::stri
|
||||
auto desc = std::make_shared<vehicle_desc>();
|
||||
desc->type = ctx_type;
|
||||
desc->path = path;
|
||||
vehicles.emplace(path, desc);
|
||||
vehicles.try_emplace(path, desc);
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +47,11 @@ TModelsManager::LoadModel(std::string const &Name, std::string const &virtualNam
|
||||
m_models.emplace_back();
|
||||
auto model = m_models.back().LoadModel( Name, dynamic );
|
||||
if( model != nullptr ) {
|
||||
m_modelsmap.emplace( virtualName, m_models.size() - 1 );
|
||||
m_modelsmap.try_emplace( virtualName, m_models.size() - 1 );
|
||||
}
|
||||
else {
|
||||
m_models.pop_back();
|
||||
m_modelsmap.emplace( virtualName, null_handle );
|
||||
m_modelsmap.try_emplace( virtualName, null_handle );
|
||||
}
|
||||
return model;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ TModelsManager::GetModel(std::string const &Name, bool const Dynamic, bool const
|
||||
ErrorLog( "Bad file: failed to locate 3d model file \"" + filename + "\"", logtype::file );
|
||||
}
|
||||
// ...and link it with the error model slot
|
||||
m_modelsmap.emplace( filename + postfix, null_handle );
|
||||
m_modelsmap.try_emplace( filename + postfix, null_handle );
|
||||
}
|
||||
Global.asCurrentTexturePath = buftp; // odtworzenie ścieżki do tekstur
|
||||
return model; // NULL jeśli błąd
|
||||
|
||||
@@ -211,7 +211,7 @@ void network::tcp::client::handle_accept(const asio::error_code &err) const
|
||||
}
|
||||
|
||||
network::tcp::asio_manager::asio_manager() {
|
||||
backend_list().emplace("tcp", this);
|
||||
backend_list().try_emplace("tcp", this);
|
||||
}
|
||||
|
||||
std::shared_ptr<network::server> network::tcp::asio_manager::create_server(std::shared_ptr<std::fstream> backbuffer, const std::string &conf) {
|
||||
|
||||
@@ -79,7 +79,7 @@ void network::request_command::deserialize(std::istream &stream)
|
||||
sequence.emplace_back(data);
|
||||
}
|
||||
|
||||
commands.emplace(recipient, sequence);
|
||||
commands.try_emplace(recipient, sequence);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ void network::server::handle_message(std::shared_ptr<connection> conn, const mes
|
||||
const auto& cmd = dynamic_cast<const request_command&>(msg);
|
||||
|
||||
for (auto const &kv : cmd.commands)
|
||||
client_commands_queue.emplace(kv);
|
||||
client_commands_queue.try_emplace(kv.first, kv.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ particle_manager::find( std::string const &Template ) {
|
||||
// if deserialization didn't fail finish source setup...
|
||||
source.m_opacitymodifier.bind( &Global.SmokeFidelity );
|
||||
// ...then cache the source as template for future instances
|
||||
m_sourcetemplates.emplace( templatename, source );
|
||||
m_sourcetemplates.try_emplace( templatename, source );
|
||||
// should be 'safe enough' to return lookup result directly afterwards
|
||||
return &( m_sourcetemplates.find( templatename )->second );
|
||||
}
|
||||
|
||||
@@ -526,7 +526,7 @@ auto python_taskqueue::fetch_renderer(std::string const Renderer) -> PyObject *
|
||||
}
|
||||
release_lock();
|
||||
// cache the failures as well so we don't try again on subsequent requests
|
||||
m_renderers.emplace(Renderer, renderer);
|
||||
m_renderers.try_emplace(Renderer, renderer);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ uart_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;
|
||||
|
||||
@@ -278,7 +278,7 @@ TGauge::Load_mapping( cParser &Input, TGauge::scratch_data &Scratchpad ) {
|
||||
auto const indexstart { key.find_first_of( "-1234567890" ) };
|
||||
auto const indexend { key.find_first_not_of( "-1234567890", indexstart ) };
|
||||
if( indexstart != std::string::npos ) {
|
||||
m_soundfxvalues.emplace(
|
||||
m_soundfxvalues.try_emplace(
|
||||
std::stoi( key.substr( indexstart, indexend - indexstart ) ),
|
||||
sound_source( m_soundtemplate ).deserialize( Input, sound_type::single ) );
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ void control_mapper::insert(TGauge const &Gauge, std::string const &Label)
|
||||
|
||||
if (Gauge.SubModel != nullptr)
|
||||
{
|
||||
m_controlnames.emplace(Gauge.SubModel, Label);
|
||||
m_controlnames.try_emplace(Gauge.SubModel, Label);
|
||||
}
|
||||
if (Gauge.SubModelOn != nullptr)
|
||||
{
|
||||
m_controlnames.emplace(Gauge.SubModelOn, Label);
|
||||
m_controlnames.try_emplace(Gauge.SubModelOn, Label);
|
||||
}
|
||||
|
||||
m_names.emplace(Label);
|
||||
|
||||
@@ -25,7 +25,7 @@ map::sorted_object_list map::objects::find_in_range(glm::vec3 from, float distan
|
||||
float dist = glm::distance2(entry_location, search_point);
|
||||
if (dist < max_distance2)
|
||||
{
|
||||
items.emplace(dist, entry);
|
||||
items.try_emplace(dist, entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ map::sorted_object_list map::objects::find_in_range(glm::vec3 from, float distan
|
||||
auto entry = std::make_shared<map::vehicle>();
|
||||
entry->dynobj = dynobj;
|
||||
entry->name = dynobj->name();
|
||||
items.emplace(dist, std::move(entry));
|
||||
items.try_emplace(dist, std::move(entry));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user