From 14a1a712de801ac11fd6203d6169abc194eab5b3 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Tue, 18 Jul 2017 08:18:13 +0200 Subject: Very little performance fix on correctBlockNodeIds + C++11 codestyle --- src/mapblock.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/mapblock.cpp b/src/mapblock.cpp index bf7f9dcd3..ed4f09692 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -492,19 +492,17 @@ static void correctBlockNodeIds(const NameIdMapping *nimap, MapNode *nodes, // the information to convert those to names. // nodedef contains information to convert our names to globally // correct ids. - std::set unnamed_contents; - std::set unallocatable_contents; + std::unordered_set unnamed_contents; + std::unordered_set unallocatable_contents; for (u32 i = 0; i < MapBlock::nodecount; i++) { content_t local_id = nodes[i].getContent(); std::string name; - bool found = nimap->getName(local_id, name); - if(!found){ + if (!nimap->getName(local_id, name)) { unnamed_contents.insert(local_id); continue; } content_t global_id; - found = nodedef->getId(name, global_id); - if(!found){ + if (!nodedef->getId(name, global_id)) { global_id = gamedef->allocateUnknownNodeId(name); if(global_id == CONTENT_IGNORE){ unallocatable_contents.insert(name); @@ -513,19 +511,16 @@ static void correctBlockNodeIds(const NameIdMapping *nimap, MapNode *nodes, } nodes[i].setContent(global_id); } - for(std::set::const_iterator - i = unnamed_contents.begin(); - i != unnamed_contents.end(); ++i){ - errorstream<<"correctBlockNodeIds(): IGNORING ERROR: " - <<"Block contains id "<<(*i) - <<" with no name mapping"<::const_iterator - i = unallocatable_contents.begin(); - i != unallocatable_contents.end(); ++i){ - errorstream<<"correctBlockNodeIds(): IGNORING ERROR: " - <<"Could not allocate global id for node name \"" - <<(*i)<<"\""<