empty() is guaranteed to be constant complexity for both vectors and lists, while size() has linear complexity for lists.
weather = pre + weather + post;
weather.erase(weather.length() - 1);
_weather.push_back(weather);
- if( w.phenomena.size() > 0 )
+ if( ! w.phenomena.empty() )
_weather2.push_back( w );
_grpcount++;
return true;
fprintf(fp, "\n");
// dump individual triangles if they exist
- if ( tris_v.size() > 0 ) {
+ if ( ! tris_v.empty() ) {
fprintf(fp, "# triangle groups\n");
int start = 0;
}
// dump triangle groups
- if ( strips_v.size() > 0 ) {
+ if ( ! strips_v.empty() ) {
fprintf(fp, "# triangle strips\n");
int start = 0;
// append another piece to the existing path
void SGPath::append( const string& p ) {
- if ( path.size() == 0 ) {
+ if ( path.empty() ) {
path = p;
} else {
if ( p[0] != sgDirPathSep ) {
// concatenate a string to the end of the path without inserting a
// path separator
void SGPath::concat( const string& p ) {
- if ( path.size() == 0 ) {
+ if ( path.empty() ) {
path = p;
} else {
path += p;
string_list sgPathBranchSplit( const string &dirpath ) {
string_list path_elements;
string element, path = dirpath;
- while ( path.size() ) {
+ while ( ! path.empty() ) {
size_t p = path.find( sgDirPathSep );
if ( p != string::npos ) {
element = path.substr( 0, p );
element = path;
path = "";
}
- if ( element.size() )
+ if ( ! element.empty() )
path_elements.push_back( element );
}
return path_elements;
virtual ~TiedPropertyList()
{
_root = 0;
- if (size()>0)
+ if (! empty())
{
SG_LOG(SG_GENERAL, SG_ALERT, "Detected properties with dangling ties. Use 'Untie' before removing a TiedPropertyList.");
// running debug mode: go, fix it!
- assert(size() == 0);
+ assert(empty());
}
}
}
void Untie() {
- while( size() > 0 ) {
+ while( ! empty() ) {
SG_LOG( SG_GENERAL, SG_DEBUG, "untie of " << back()->getPath() );
back()->untie();
pop_back();
PropertyList useProps = prop->getChildren("use");
if (useProps.size() == 1) {
string parentName = useProps[0]->getStringValue();
- if (parentName.size() == 0 || parentName[0] != '/')
+ if (parentName.empty() || parentName[0] != '/')
parentName = options->getPropertyNode()->getPath() + "/" + parentName;
if (parentName[parentName.size() - 1] != '/')
parentName.append("/");
itr != end;
++itr) {
string childName = (*itr)->getStringValue();
- if (childName.size() == 0 || childName[0] != '/')
+ if (childName.empty() || childName[0] != '/')
result.push_back(parentName + childName);
else
result.push_back(childName);
BOOST_FOREACH(ref_ptr<Pass>& pass, passes)
{
osg::ref_ptr<osg::StateSet> ss = pass;
- if (ecv && ( pass->getBufferUnitList().size() != 0 || pass->getPositionedUniformMap().size() != 0 ) ) {
+ if (ecv && ( ! pass->getBufferUnitList().empty() || ! pass->getPositionedUniformMap().empty() ) ) {
ss = static_cast<osg::StateSet*>(
- pass->clone( osg::CopyOp( ( pass->getBufferUnitList().size() != 0 ?
+ pass->clone( osg::CopyOp( ( ! pass->getBufferUnitList().empty() ?
osg::CopyOp::DEEP_COPY_TEXTURES :
osg::CopyOp::SHALLOW_COPY ) |
- ( pass->getPositionedUniformMap().size() != 0 ?
+ ( ! pass->getPositionedUniformMap().empty() ?
osg::CopyOp::DEEP_COPY_UNIFORMS :
osg::CopyOp::SHALLOW_COPY ) )
)
}
}
- if (textures.size() == 0 && texturesets.size() == 0) {
+ if (textures.empty() && texturesets.empty()) {
SGPath tpath("Textures");
tpath.append("Terrain");
tpath.append("unknown.rgb");
Effect* SGMaterial::get_effect(const SGTexturedTriangleBin& triangleBin)
{
- if (_status.size() == 0) {
+ if (_status.empty()) {
SG_LOG( SG_GENERAL, SG_WARN, "No effect available.");
return 0;
}
osg::Texture2D* SGMaterial::get_object_mask(const SGTexturedTriangleBin& triangleBin)
{
- if (_status.size() == 0) {
+ if (_status.empty()) {
SG_LOG( SG_GENERAL, SG_WARN, "No mask available.");
return 0;
}
numeric( aNumeric ),
format( aFormat )
{
- if( format.size() == 0 ) {
+ if( format.empty() ) {
if( numeric ) format = "%f";
else format = "%s";
}
{
void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const
{
- if (!_cloudsprites.size()) return;
+ if (_cloudsprites.empty()) return;
osg::State& state = *renderInfo.getState();
}
bool SGCloudField::isDefined3D(void) {
- return (cloud_hash.size() > 0);
+ return (! cloud_hash.empty());
}
SGCloudField::CloudFog::CloudFog() {
}
}
- if (newmat.size()) {
+ if (! newmat.empty()) {
material = d->materials->find(newmat);
newmat.clear();
}
randomObjects->setName("Random objects");
}
- if (tileGeometryBin.randomBuildings.size() > 0) {
+ if (! tileGeometryBin.randomBuildings.empty()) {
buildingNode = createRandomBuildings(tileGeometryBin.randomBuildings, osg::Matrix::identity(),
options);
buildingNode->setName("Random buildings");
// Now add some random forest.
tileGeometryBin.computeRandomForest(matlib, vegetation_density);
- if (tileGeometryBin.randomForest.size() > 0) {
+ if (! tileGeometryBin.randomForest.empty()) {
forestNode = createForest(tileGeometryBin.randomForest, osg::Matrix::identity(),
options);
forestNode->setName("Random trees");