Performance optimization: empty() instead of size()>0

empty() is guaranteed to be constant complexity for both vectors and lists, while size() has linear complexity for lists.
This commit is contained in:
Tom Paoletti
2013-08-16 16:48:35 +01:00
committed by James Turner
parent ee403fd83a
commit 15e3e92ec2
12 changed files with 24 additions and 24 deletions
+3 -3
View File
@@ -37,11 +37,11 @@ public:
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());
}
}
@@ -124,7 +124,7 @@ public:
}
void Untie() {
while( size() > 0 ) {
while( ! empty() ) {
SG_LOG( SG_GENERAL, SG_DEBUG, "untie of " << back()->getPath() );
back()->untie();
pop_back();