mirror of
https://github.com/luanti-org/luanti.git
synced 2025-12-05 15:15:25 +01:00
Use emplace instead of insert where applicable (#16699)
This commit is contained in:
@@ -99,7 +99,7 @@ void ClientMediaDownloader::addFile(const std::string &name, const std::string &
|
||||
filestatus->received = false;
|
||||
filestatus->sha1 = sha1;
|
||||
filestatus->current_remote = -1;
|
||||
m_files.insert(std::make_pair(name, filestatus));
|
||||
m_files.emplace(name, filestatus);
|
||||
}
|
||||
|
||||
void ClientMediaDownloader::addRemoteServer(const std::string &baseurl)
|
||||
@@ -427,9 +427,9 @@ void ClientMediaDownloader::startRemoteMediaTransfers()
|
||||
(long)g_settings->getS32("curl_file_download_timeout"));
|
||||
httpfetch_async(fetch_request);
|
||||
|
||||
m_remote_file_transfers.insert(std::make_pair(
|
||||
m_remote_file_transfers.emplace(
|
||||
m_httpfetch_next_id,
|
||||
name));
|
||||
name);
|
||||
|
||||
filestatus->current_remote = remote_id;
|
||||
remote->active_count++;
|
||||
|
||||
@@ -80,7 +80,7 @@ void MinimapUpdateThread::doUpdate()
|
||||
while (popBlockUpdate(&update)) {
|
||||
if (update.data) {
|
||||
// Swap two values in the map using single lookup
|
||||
auto result = m_blocks_cache.insert(std::make_pair(update.pos, update.data));
|
||||
auto result = m_blocks_cache.emplace(update.pos, update.data);
|
||||
if (!result.second) {
|
||||
delete result.first->second;
|
||||
result.first->second = update.data;
|
||||
|
||||
@@ -390,7 +390,7 @@ bool EmergeManager::pushBlockEmergeData(
|
||||
}
|
||||
}
|
||||
|
||||
auto findres = m_blocks_enqueued.insert(std::make_pair(pos, BlockEmergeData()));
|
||||
auto findres = m_blocks_enqueued.emplace(pos, BlockEmergeData());
|
||||
|
||||
BlockEmergeData &bedata = findres.first->second;
|
||||
*entry_already_exists = !findres.second;
|
||||
|
||||
@@ -466,22 +466,22 @@ public:
|
||||
hand_def->name.clear();
|
||||
hand_def->wield_image = "wieldhand.png";
|
||||
hand_def->tool_capabilities = new ToolCapabilities;
|
||||
m_item_definitions.insert(std::make_pair("", hand_def));
|
||||
m_item_definitions.emplace("", hand_def);
|
||||
|
||||
ItemDefinition* unknown_def = new ItemDefinition;
|
||||
unknown_def->type = ITEM_NODE;
|
||||
unknown_def->name = "unknown";
|
||||
m_item_definitions.insert(std::make_pair("unknown", unknown_def));
|
||||
m_item_definitions.emplace("unknown", unknown_def);
|
||||
|
||||
ItemDefinition* air_def = new ItemDefinition;
|
||||
air_def->type = ITEM_NODE;
|
||||
air_def->name = "air";
|
||||
m_item_definitions.insert(std::make_pair("air", air_def));
|
||||
m_item_definitions.emplace("air", air_def);
|
||||
|
||||
ItemDefinition* ignore_def = new ItemDefinition;
|
||||
ignore_def->type = ITEM_NODE;
|
||||
ignore_def->name = "ignore";
|
||||
m_item_definitions.insert(std::make_pair("ignore", ignore_def));
|
||||
m_item_definitions.emplace("ignore", ignore_def);
|
||||
}
|
||||
|
||||
virtual void registerItem(const ItemDefinition &def)
|
||||
|
||||
@@ -178,8 +178,7 @@ bool VectorAreaStore::insertArea(Area *a)
|
||||
{
|
||||
if (a->id == U32_MAX)
|
||||
a->id = getNextId();
|
||||
std::pair<AreaMap::iterator, bool> res =
|
||||
areas_map.insert(std::make_pair(a->id, *a));
|
||||
auto res = areas_map.emplace(a->id, *a);
|
||||
if (!res.second)
|
||||
// ID is not unique
|
||||
return false;
|
||||
@@ -249,7 +248,7 @@ bool SpatialAreaStore::insertArea(Area *a)
|
||||
{
|
||||
if (a->id == U32_MAX)
|
||||
a->id = getNextId();
|
||||
if (!areas_map.insert(std::make_pair(a->id, *a)).second)
|
||||
if (!areas_map.emplace(a->id, *a).second)
|
||||
// ID is not unique
|
||||
return false;
|
||||
m_tree->insertData(0, nullptr, get_spatial_region(a->minedge, a->maxedge), a->id);
|
||||
|
||||
Reference in New Issue
Block a user