Use empty() instead of !size()

move
scrawl 9 years ago
parent 8bd16e4d5a
commit 90a99991d1

@ -158,7 +158,7 @@ public:
} }
// resolve overlapping keywords // resolve overlapping keywords
while (matches.size()) while (!matches.empty())
{ {
int longestKeywordSize = 0; int longestKeywordSize = 0;
typename std::vector<Match>::iterator longestKeyword = matches.begin(); typename std::vector<Match>::iterator longestKeyword = matches.begin();

@ -240,7 +240,7 @@ namespace MWGui
mCommandLine->setCaption(newCaption); mCommandLine->setCaption(newCaption);
// List candidates if repeatedly pressing tab // List candidates if repeatedly pressing tab
if (oldCaption == newCaption && matches.size()) if (oldCaption == newCaption && !matches.empty())
{ {
int i = 0; int i = 0;
printOK(""); printOK("");

@ -37,7 +37,7 @@ ContainerItemModel::ContainerItemModel(const std::vector<MWWorld::Ptr>& itemSour
: mItemSources(itemSources) : mItemSources(itemSources)
, mWorldItems(worldItems) , mWorldItems(worldItems)
{ {
assert (mItemSources.size()); assert (!mItemSources.empty());
} }
ContainerItemModel::ContainerItemModel (const MWWorld::Ptr& source) ContainerItemModel::ContainerItemModel (const MWWorld::Ptr& source)

@ -255,7 +255,7 @@ namespace MWMechanics
// Construct a new path if there isn't one // Construct a new path if there isn't one
if(!storage.mPathFinder.isPathConstructed()) if(!storage.mPathFinder.isPathConstructed())
{ {
if (mAllowedNodes.size()) if (!mAllowedNodes.empty())
{ {
setPathToAnAllowedNode(actor, storage, pos); setPathToAnAllowedNode(actor, storage, pos);
} }

@ -2155,7 +2155,7 @@ void CharacterController::updateHeadTracking(float duration)
if (node != NULL) if (node != NULL)
{ {
osg::NodePathList nodepaths = node->getParentalNodePaths(); osg::NodePathList nodepaths = node->getParentalNodePaths();
if (nodepaths.size()) if (!nodepaths.empty())
direction = osg::computeLocalToWorld(nodepaths[0]).getTrans() - headPos; direction = osg::computeLocalToWorld(nodepaths[0]).getTrans() - headPos;
} }
else else

@ -366,7 +366,7 @@ namespace MWRender
// Now update camera utilizing the updated head position // Now update camera utilizing the updated head position
osg::NodePathList nodepaths = mNodeToFollow->getParentalNodePaths(); osg::NodePathList nodepaths = mNodeToFollow->getParentalNodePaths();
if (!nodepaths.size()) if (nodepaths.empty())
return; return;
osg::Matrix worldMat = osg::computeLocalToWorld(nodepaths[0]); osg::Matrix worldMat = osg::computeLocalToWorld(nodepaths[0]);
osg::Vec3 headOffset = worldMat.getTrans(); osg::Vec3 headOffset = worldMat.getTrans();

@ -402,7 +402,7 @@ namespace MWRender
|| bounds.mMinY > bounds.mMaxY) || bounds.mMinY > bounds.mMaxY)
throw std::runtime_error("invalid map bounds"); throw std::runtime_error("invalid map bounds");
if (!map.mImageData.size()) if (map.mImageData.empty())
return; return;
Files::IMemStream istream(&map.mImageData[0], map.mImageData.size()); Files::IMemStream istream(&map.mImageData[0], map.mImageData.size());

@ -632,7 +632,7 @@ void LocalMap::MapSegment::initFogOfWar()
void LocalMap::MapSegment::loadFogOfWar(const ESM::FogTexture &esm) void LocalMap::MapSegment::loadFogOfWar(const ESM::FogTexture &esm)
{ {
const std::vector<char>& data = esm.mImageData; const std::vector<char>& data = esm.mImageData;
if (!data.size()) if (data.empty())
{ {
initFogOfWar(); initFogOfWar();
return; return;

@ -566,7 +566,7 @@ void Water::createSimpleWaterStateSet(osg::Node* node, float alpha)
textures.push_back(tex); textures.push_back(tex);
} }
if (!textures.size()) if (textures.empty())
return; return;
float fps = mFallback->getFallbackFloat("Water_SurfaceFPS"); float fps = mFallback->getFallbackFloat("Water_SurfaceFPS");

@ -366,7 +366,7 @@ namespace MWSound
else else
filelist = mMusicFiles[mCurrentPlaylist]; filelist = mMusicFiles[mCurrentPlaylist];
if(!filelist.size()) if(filelist.empty())
return; return;
int i = Misc::Rng::rollDice(filelist.size()); int i = Misc::Rng::rollDice(filelist.size());

@ -53,14 +53,14 @@ void ESM::Header::load (ESMReader &esm)
{ {
esm.getSubHeader(); esm.getSubHeader();
mSCRD.resize(esm.getSubSize()); mSCRD.resize(esm.getSubSize());
if (mSCRD.size()) if (!mSCRD.empty())
esm.getExact(&mSCRD[0], mSCRD.size()); esm.getExact(&mSCRD[0], mSCRD.size());
} }
if (esm.isNextSub("SCRS")) if (esm.isNextSub("SCRS"))
{ {
esm.getSubHeader(); esm.getSubHeader();
mSCRS.resize(esm.getSubSize()); mSCRS.resize(esm.getSubSize());
if (mSCRS.size()) if (!mSCRS.empty())
esm.getExact(&mSCRS[0], mSCRS.size()); esm.getExact(&mSCRS[0], mSCRS.size());
} }
} }

@ -962,7 +962,7 @@ namespace NifOsg
if (uvSet >= (int)data->uvlist.size()) if (uvSet >= (int)data->uvlist.size())
{ {
std::cerr << "Warning: out of bounds UV set " << uvSet << " on TriShape \"" << triShape->name << "\" in " << mFilename << std::endl; std::cerr << "Warning: out of bounds UV set " << uvSet << " on TriShape \"" << triShape->name << "\" in " << mFilename << std::endl;
if (data->uvlist.size()) if (!data->uvlist.empty())
geometry->setTexCoordArray(textureStage, data->uvlist[0]); geometry->setTexCoordArray(textureStage, data->uvlist[0]);
continue; continue;
} }
@ -1040,7 +1040,7 @@ namespace NifOsg
triShapeToGeometry(triShape, morphGeom, parentNode, composite, boundTextures, animflags); triShapeToGeometry(triShape, morphGeom, parentNode, composite, boundTextures, animflags);
const std::vector<Nif::NiMorphData::MorphData>& morphs = morpher->data.getPtr()->mMorphs; const std::vector<Nif::NiMorphData::MorphData>& morphs = morpher->data.getPtr()->mMorphs;
if (!morphs.size()) if (morphs.empty())
return morphGeom; return morphGeom;
// Note we are not interested in morph 0, which just contains the original vertices // Note we are not interested in morph 0, which just contains the original vertices
for (unsigned int i = 1; i < morphs.size(); ++i) for (unsigned int i = 1; i < morphs.size(); ++i)
@ -1228,7 +1228,7 @@ namespace NifOsg
return NULL; return NULL;
} }
if (!pixelData->mipmaps.size()) if (pixelData->mipmaps.empty())
return NULL; return NULL;
unsigned char* data = new unsigned char[pixelData->data.size()]; unsigned char* data = new unsigned char[pixelData->data.size()];
@ -1274,7 +1274,7 @@ namespace NifOsg
void handleTextureProperty(const Nif::NiTexturingProperty* texprop, osg::StateSet* stateset, SceneUtil::CompositeStateSetUpdater* composite, Resource::ImageManager* imageManager, std::vector<int>& boundTextures, int animflags) void handleTextureProperty(const Nif::NiTexturingProperty* texprop, osg::StateSet* stateset, SceneUtil::CompositeStateSetUpdater* composite, Resource::ImageManager* imageManager, std::vector<int>& boundTextures, int animflags)
{ {
if (boundTextures.size()) if (!boundTextures.empty())
{ {
// overriding a parent NiTexturingProperty, so remove what was previously bound // overriding a parent NiTexturingProperty, so remove what was previously bound
for (unsigned int i=0; i<boundTextures.size(); ++i) for (unsigned int i=0; i<boundTextures.size(); ++i)

@ -262,7 +262,7 @@ void Emitter::emitParticles(double dt)
// maybe this could be optimized by halting at the lowest common ancestor of the particle and emitter nodes // maybe this could be optimized by halting at the lowest common ancestor of the particle and emitter nodes
osg::NodePathList partsysNodePaths = getParticleSystem()->getParentalNodePaths(); osg::NodePathList partsysNodePaths = getParticleSystem()->getParentalNodePaths();
if (partsysNodePaths.size()) if (!partsysNodePaths.empty())
{ {
osg::Matrix psToWorld = osg::computeLocalToWorld(partsysNodePaths[0]); osg::Matrix psToWorld = osg::computeLocalToWorld(partsysNodePaths[0]);
worldToPs = osg::Matrix::inverse(psToWorld); worldToPs = osg::Matrix::inverse(psToWorld);

@ -351,7 +351,7 @@ namespace SceneUtil
mLightList.push_back(&l); mLightList.push_back(&l);
} }
} }
if (mLightList.size()) if (!mLightList.empty())
{ {
unsigned int maxLights = static_cast<unsigned int> (8 - mLightManager->getStartLight()); unsigned int maxLights = static_cast<unsigned int> (8 - mLightManager->getStartLight());

@ -87,7 +87,7 @@ osg::ref_ptr<WorkItem> WorkQueue::removeWorkItem()
{ {
mCondition.wait(&mMutex); mCondition.wait(&mMutex);
} }
if (mQueue.size()) if (!mQueue.empty())
{ {
osg::ref_ptr<WorkItem> item = mQueue.front(); osg::ref_ptr<WorkItem> item = mQueue.front();
mQueue.pop(); mQueue.pop();

@ -103,7 +103,7 @@ namespace Shader
if (mAllowedToModifyStateSets) if (mAllowedToModifyStateSets)
writableStateSet = node.getStateSet(); writableStateSet = node.getStateSet();
const osg::StateSet::TextureAttributeList& texAttributes = stateset->getTextureAttributeList(); const osg::StateSet::TextureAttributeList& texAttributes = stateset->getTextureAttributeList();
if (texAttributes.size()) if (!texAttributes.empty())
{ {
const osg::Texture* diffuseMap = NULL; const osg::Texture* diffuseMap = NULL;
const osg::Texture* normalMap = NULL; const osg::Texture* normalMap = NULL;

Loading…
Cancel
Save