Use std::string::empty() instead of size() where applicable
authorAnton <vob999@bk.ru>
Fri, 12 Dec 2014 14:55:40 +0000 (19:55 +0500)
committerShadowNinja <shadowninja@minetest.net>
Fri, 12 Dec 2014 20:16:24 +0000 (15:16 -0500)
14 files changed:
src/client.cpp
src/clientiface.cpp
src/connection.cpp
src/content_cao.cpp
src/environment.cpp
src/mainmenumanager.h
src/map.cpp
src/mg_decoration.cpp
src/nodedef.cpp
src/nodemetadata.cpp
src/nodetimer.cpp
src/server.cpp
src/sound_openal.cpp
src/voxel.cpp

index 5b4eb7d10f46f2fc67ee7b9a521ddb4c803edbc8..d48231883f03c842d3a4a694955be626220c1278 100644 (file)
@@ -577,7 +577,7 @@ void Client::step(float dtime)
                {
                        if(sendlist.size() == 255 || i == deleted_blocks.end())
                        {
-                               if(sendlist.size() == 0)
+                               if(sendlist.empty())
                                        break;
                                /*
                                        [0] u16 command
@@ -813,7 +813,7 @@ void Client::step(float dtime)
                        }
                }
                // Sync to server
-               if(removed_server_ids.size() != 0)
+               if(!removed_server_ids.empty())
                {
                        std::ostringstream os(std::ios_base::binary);
                        writeU16(os, TOSERVER_REMOVED_SOUNDS);
index cd2e2d4d95af68343bc1ce1ab9642f583a771ecc..1383d0b84a5f8b53e01986b928cb8efb4d797650 100644 (file)
@@ -603,7 +603,7 @@ void ClientInterface::UpdatePlayerList()
                m_clients_names.clear();
 
 
-               if(clients.size() != 0)
+               if(!clients.empty())
                        infostream<<"Players:"<<std::endl;
                for(std::list<u16>::iterator
                        i = clients.begin();
index 64ef9a50e42f9638008adeb0f9273190212068f8..cf5be7ed6aaebe4779da849fc8bf932a0e95478a 100644 (file)
@@ -1316,7 +1316,7 @@ bool ConnectionSendThread::packetsQueued()
 {
        std::list<u16> peerIds = m_connection->getPeerIDs();
 
-       if ((this->m_outgoing_queue.size() > 0) && (peerIds.size() > 0))
+       if (!m_outgoing_queue.empty() && !peerIds.empty())
                return true;
 
        for(std::list<u16>::iterator j = peerIds.begin();
index 8471b7e81408eec598b5542b56cb2370786576f1..671ddd4b1afc241667b734229b4c49b176f3b349 100644 (file)
@@ -1468,7 +1468,7 @@ void GenericCAO::updateAnimation()
 
 void GenericCAO::updateBonePosition()
 {
-       if(!m_bone_position.size() || m_animated_meshnode == NULL)
+       if(m_bone_position.empty() || m_animated_meshnode == NULL)
                return;
 
        m_animated_meshnode->setJointMode(irr::scene::EJUOR_CONTROL); // To write positions to the mesh on render
index d7c8acee8c52c4cc3934481d2df9848f843921ba..ee4488476455293e06d41296b4c925e31034324e 100644 (file)
@@ -1669,7 +1669,7 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
        if(block==NULL)
                return;
        // Ignore if no stored objects (to not set changed flag)
-       if(block->m_static_objects.m_stored.size() == 0)
+       if(block->m_static_objects.m_stored.empty())
                return;
        verbosestream<<"ServerEnvironment::activateObjects(): "
                        <<"activating objects of block "<<PP(block->getPos())
index db8aa9e19f5d5b21fafcb8937e98332601f59f93..b14ca56e51c84f912d33a82603a2f000c375c8ae 100644 (file)
@@ -56,7 +56,7 @@ public:
                        assert(*i != menu);
                }
 
-               if(m_stack.size() != 0)
+               if(!m_stack.empty())
                        m_stack.back()->setVisible(false);
                m_stack.push_back(menu);
        }
@@ -84,14 +84,14 @@ public:
                assert(*i == menu);
                m_stack.erase(i);*/
                
-               if(m_stack.size() != 0)
+               if(!m_stack.empty())
                        m_stack.back()->setVisible(true);
        }
 
        // Returns true to prevent further processing
        virtual bool preprocessEvent(const SEvent& event)
        {
-               if(m_stack.size() != 0)
+               if(!m_stack.empty())
                        return m_stack.back()->preprocessEvent(event);
                else
                        return false;
index 4b0d2e2d8e846d8e5ee664ece1e245a8e4b4faaa..009bc3d72e6c191aa483764f4ec250d2a4e3b256 100644 (file)
@@ -276,7 +276,7 @@ void Map::unspreadLight(enum LightBank bank,
                v3s16(-1,0,0), // left
        };
 
-       if(from_nodes.size() == 0)
+       if(from_nodes.empty())
                return;
 
        u32 blockchangecount = 0;
@@ -418,7 +418,7 @@ void Map::unspreadLight(enum LightBank bank,
                        <<" for "<<from_nodes.size()<<" nodes"
                        <<std::endl;*/
 
-       if(unlighted_nodes.size() > 0)
+       if(!unlighted_nodes.empty())
                unspreadLight(bank, unlighted_nodes, light_sources, modified_blocks);
 }
 
@@ -455,7 +455,7 @@ void Map::spreadLight(enum LightBank bank,
                v3s16(-1,0,0), // left
        };
 
-       if(from_nodes.size() == 0)
+       if(from_nodes.empty())
                return;
 
        u32 blockchangecount = 0;
@@ -575,7 +575,7 @@ void Map::spreadLight(enum LightBank bank,
                        <<" for "<<from_nodes.size()<<" nodes"
                        <<std::endl;*/
 
-       if(lighted_nodes.size() > 0)
+       if(!lighted_nodes.empty())
                spreadLight(bank, lighted_nodes, modified_blocks);
 }
 
index 14368c091dcacdf273e17b10845e3101dac1afcc..761b231edf10c94374809626ba4c2d9731b28391 100644 (file)
@@ -155,7 +155,7 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
                        if (mg->biomemap) {
                                std::set<u8>::iterator iter;
 
-                               if (biomes.size()) {
+                               if (!biomes.empty()) {
                                        iter = biomes.find(mg->biomemap[mapindex]);
                                        if (iter == biomes.end())
                                                continue;
index 1795b199c2a022e8b23647682496d6c3a677dec7..b046957e639acf5a8c2f3678ab155781066807fe 100644 (file)
@@ -1414,7 +1414,7 @@ int NodeResolver::resolveNodes()
                for (it = idset.begin(); it != idset.end(); ++it)
                        output->push_back(*it);
 
-               if (idset.size() == 0) {
+               if (idset.empty()) {
                        num_failed++;
                        errorstream << "NodeResolver::resolveNodes():  Failed to "
                                "resolve '" << name << "'" << std::endl;
index 0631d974adfb1b31ebffa8f752c75d03473f7982..b8c7d3d9c11722cefec153c769bc2cb2df32985f 100644 (file)
@@ -83,7 +83,7 @@ void NodeMetadataList::serialize(std::ostream &os) const
                Version 0 is a placeholder for "nothing to see here; go away."
        */
 
-       if(m_data.size() == 0){
+       if(m_data.empty()){
                writeU8(os, 0); // version
                return;
        }
index d4971c8734ecb2ec44b070e02199a952dfd8eabb..790b460760324f5e5b63abfbecbe7e0ea7d13ca6 100644 (file)
@@ -47,7 +47,7 @@ void NodeTimerList::serialize(std::ostream &os, u8 map_format_version) const
 {
        if(map_format_version == 24){
                // Version 0 is a placeholder for "nothing to see here; go away."
-               if(m_data.size() == 0){
+               if(m_data.empty()){
                        writeU8(os, 0); // version
                        return;
                }
index 7c5ee7f4242f40d29cf38ffec96746bfe38b71e9..d56c34c65e7d26b3ce02becde2918cec4efa0ee9 100644 (file)
@@ -664,7 +664,7 @@ void Server::AsyncRunStep(bool initial_step)
                /*
                        Set the modified blocks unsent for all the clients
                */
-               if(modified_blocks.size() > 0)
+               if(!modified_blocks.empty())
                {
                        SetBlocksNotSent(modified_blocks);
                }
@@ -745,7 +745,7 @@ void Server::AsyncRunStep(bool initial_step)
                                        client->m_known_objects, added_objects);
 
                        // Ignore if nothing happened
-                       if(removed_objects.size() == 0 && added_objects.size() == 0)
+                       if(removed_objects.empty() && added_objects.empty())
                        {
                                //infostream<<"active objects: none changed"<<std::endl;
                                continue;
@@ -1051,7 +1051,7 @@ void Server::AsyncRunStep(bool initial_step)
                        /*
                                Set blocks not sent to far players
                        */
-                       if(far_players.size() > 0)
+                       if(!far_players.empty())
                        {
                                // Convert list format to that wanted by SetBlocksNotSent
                                std::map<v3s16, MapBlock*> modified_blocks2;
@@ -2675,7 +2675,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                                continue;
                        ServerPlayingSound &psound = i->second;
                        psound.clients.erase(peer_id);
-                       if(psound.clients.size() == 0)
+                       if(psound.clients.empty())
                                m_playing_sounds.erase(i++);
                }
        }
@@ -3628,7 +3628,7 @@ s32 Server::playSound(const SimpleSoundSpec &spec,
                        dst_clients.push_back(*i);
                }
        }
-       if(dst_clients.size() == 0)
+       if(dst_clients.empty())
                return -1;
 
        // Create the sound
@@ -4322,7 +4322,7 @@ void Server::DeleteClient(u16 peer_id, ClientDeletionReason reason)
                {
                        ServerPlayingSound &psound = i->second;
                        psound.clients.erase(peer_id);
-                       if(psound.clients.size() == 0)
+                       if(psound.clients.empty())
                                m_playing_sounds.erase(i++);
                        else
                                i++;
index d27526b55b5522877c8a0b5bfb8f52a663a14c66..b2b424a19301f6c1b1c34f116bb0da3e0e939d61 100644 (file)
@@ -434,7 +434,7 @@ public:
                                }
                        }
                }
-               if(del_list.size() != 0)
+               if(!del_list.empty())
                        verbosestream<<"OpenALSoundManager::maintain(): deleting "
                                        <<del_list.size()<<" playing sounds"<<std::endl;
                for(std::set<int>::iterator i = del_list.begin();
index e6d4bdcd22587d5bad6895f61e337f8df029f9bf..335ab307c97f49d00239c211586c9e28eef9ad8a 100644 (file)
@@ -420,7 +420,7 @@ void VoxelManipulator::unspreadLight(enum LightBank bank,
                std::map<v3s16, u8> & from_nodes,
                std::set<v3s16> & light_sources, INodeDefManager *nodemgr)
 {
-       if(from_nodes.size() == 0)
+       if(from_nodes.empty())
                return;
 
        for(std::map<v3s16, u8>::iterator j = from_nodes.begin();
@@ -646,7 +646,7 @@ void VoxelManipulator::spreadLight(enum LightBank bank,
                v3s16(-1,0,0), // left
        };
 
-       if(from_nodes.size() == 0)
+       if(from_nodes.empty())
                return;
 
        std::set<v3s16> lighted_nodes;
@@ -719,7 +719,7 @@ void VoxelManipulator::spreadLight(enum LightBank bank,
                        <<" for "<<from_nodes.size()<<" nodes"
                        <<std::endl;*/
 
-       if(lighted_nodes.size() > 0)
+       if(!lighted_nodes.empty())
                spreadLight(bank, lighted_nodes, nodemgr);
 }
 #endif