Use std::string::empty() instead of size() where applicable

master
Anton 2014-12-12 19:55:40 +05:00 committed by ShadowNinja
parent 83830e8682
commit 10e0cf8b2c
14 changed files with 27 additions and 27 deletions

View 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);

View 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();

View 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();

View 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

View 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())

View 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;

View 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);
}

View 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;

View 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;

View 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;
}

View 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;
}

View 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++;

View 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();

View 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