]> git.mxchange.org Git - flightgear.git/commitdiff
Performance optimization: empty() instead of size()>0
authorTom Paoletti <zommaso@gmail.com>
Fri, 22 Mar 2013 02:42:22 +0000 (19:42 -0700)
committerJames Turner <zakalawe@mac.com>
Mon, 19 Aug 2013 08:01:59 +0000 (09:01 +0100)
empty() is guaranteed to be constant complexity for both vectors and lists, while size() has linear complexity for lists.

22 files changed:
src/ATC/trafficcontrol.cxx
src/ATC/trafficcontrol.hxx
src/Aircraft/replay.cxx
src/Airports/apt_loader.cxx
src/Autopilot/analogcomponent.hxx
src/Input/FGKeyboardInput.cxx
src/Instrumentation/HUD/HUD.cxx
src/Instrumentation/HUD/HUD.hxx
src/Instrumentation/KLN89/kln89.cxx
src/Instrumentation/dclgps.hxx
src/Instrumentation/mk_viii.cxx
src/Instrumentation/newnavradio.cxx
src/Main/locale.cxx
src/Main/logger.cxx
src/Main/metar_main.cxx
src/Main/options.cxx
src/Main/positioninit.cxx
src/Main/subsystemFactory.cxx
src/Network/generic.cxx
src/Sound/sample_queue.cxx
src/Traffic/Schedule.cxx
src/Viewer/fg_os_osgviewer.cxx

index 137c68aebf9ef899eb6b0113a03c2c5032384de4..65d60ae529dca95546b4223598560420792df6b0 100644 (file)
@@ -65,7 +65,7 @@ time_t ActiveRunway::requestTimeSlot(time_t eta)
     time_t newEta;
     time_t separation = 90;
     bool found = false;
-    if (estimatedArrivalTimes.size() == 0) {
+    if (estimatedArrivalTimes.empty()) {
         estimatedArrivalTimes.push_back(eta);
         return eta;
     } else {
@@ -191,7 +191,7 @@ void FGTrafficRecord::setPositionAndIntentions(int pos,
 {
 
     currentPos = pos;
-    if (intentions.size()) {
+    if (! intentions.empty()) {
         intVecIterator i = intentions.begin();
         if ((*i) != pos) {
             SG_LOG(SG_ATC, SG_ALERT,
@@ -223,7 +223,7 @@ bool FGTrafficRecord::checkPositionAndIntentions(FGTrafficRecord & other)
         //cerr << callsign << ": Check Position and intentions: we are on the same taxiway" << other.callsign << "Index = " << currentPos << endl;
         result = true;
     }
-    //  else if (other.intentions.size())
+    //  else if (! other.intentions.empty())
     //     {
     //       cerr << "Start check 2" << endl;
     //       intVecIterator i = other.intentions.begin();
@@ -233,7 +233,7 @@ bool FGTrafficRecord::checkPositionAndIntentions(FGTrafficRecord & other)
     //     cerr << "Check Position and intentions: current matches other.intentions" << endl;
     //     result = true;
     //       }
-    else if (intentions.size()) {
+    else if (! intentions.empty()) {
         //cerr << "Start check 3" << endl;
         intVecIterator i = intentions.begin();
         //while (!((i == intentions.end()) || ((*i) == other.currentPos)))
@@ -277,7 +277,7 @@ int FGTrafficRecord::crosses(FGGroundNetwork * net,
         otherTargetNode = net->findSegment(other.currentPos)->getEnd()->getIndex();     // OKAY,...
     if ((currentTargetNode == otherTargetNode) && currentTargetNode > 0)
         return currentTargetNode;
-    if (intentions.size()) {
+    if (! intentions.empty()) {
         for (i = intentions.begin(); i != intentions.end(); i++) {
             if ((*i) > 0) {
                 if (currentTargetNode ==
@@ -288,7 +288,7 @@ int FGTrafficRecord::crosses(FGGroundNetwork * net,
             }
         }
     }
-    if (other.intentions.size()) {
+    if (! other.intentions.empty()) {
         for (i = other.intentions.begin(); i != other.intentions.end();
                 i++) {
             if ((*i) > 0) {
@@ -300,7 +300,7 @@ int FGTrafficRecord::crosses(FGGroundNetwork * net,
             }
         }
     }
-    if (intentions.size() && other.intentions.size()) {
+    if (! intentions.empty() && ! other.intentions.empty()) {
         for (i = intentions.begin(); i != intentions.end(); i++) {
             for (j = other.intentions.begin(); j != other.intentions.end();
                     j++) {
@@ -332,7 +332,7 @@ bool FGTrafficRecord::onRoute(FGGroundNetwork * net,
             net->findSegment(other.currentPos)->getEnd()->getIndex();
     if ((node == othernode) && (node != -1))
         return true;
-    if (other.intentions.size()) {
+    if (! other.intentions.empty()) {
         for (intVecIterator i = other.intentions.begin();
                 i != other.intentions.end(); i++) {
             if (*i > 0) {
@@ -344,7 +344,7 @@ bool FGTrafficRecord::onRoute(FGGroundNetwork * net,
     }
     //if (other.currentPos > 0)
     //  othernode = net->findSegment(other.currentPos)->getEnd()->getIndex();
-    //if (intentions.size())
+    //if (! intentions.empty())
     //  {
     //    for (intVecIterator i = intentions.begin(); i != intentions.end(); i++)
     //    {
@@ -388,7 +388,7 @@ bool FGTrafficRecord::isOpposing(FGGroundNetwork * net,
                         }
                     }
             }
-            if (other.intentions.size()) {
+            if (! other.intentions.empty()) {
                 for (intVecIterator j = other.intentions.begin();
                         j != other.intentions.end(); j++) {
                     // cerr << "Current segment 1 " << (*i) << endl;
@@ -820,7 +820,7 @@ void FGTowerController::announcePosition(int id,
     TrafficVectorIterator i = activeTraffic.begin();
     // Search whether the current id alread has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -830,7 +830,7 @@ void FGTowerController::announcePosition(int id,
         }
     }
     // Add a new TrafficRecord if no one exsists for this aircraft.
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || (activeTraffic.empty())) {
         FGTrafficRecord rec;
         rec.setId(id);
 
@@ -843,7 +843,7 @@ void FGTowerController::announcePosition(int id,
         activeTraffic.push_back(rec);
         // Don't just schedule the aircraft for the tower controller, also assign if to the correct active runway.
         ActiveRunwayVecIterator rwy = activeRunways.begin();
-        if (activeRunways.size()) {
+        if (! activeRunways.empty()) {
             while (rwy != activeRunways.end()) {
                 if (rwy->getRunwayName() == intendedRoute->getRunway()) {
                     break;
@@ -874,7 +874,7 @@ void FGTowerController::updateAircraftInformation(int id, double lat, double lon
     // Search whether the current id has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
     TrafficVectorIterator current, closest;
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -884,7 +884,7 @@ void FGTowerController::updateAircraftInformation(int id, double lat, double lon
         }
     }
 //    // update position of the current aircraft
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || (activeTraffic.empty())) {
         SG_LOG(SG_ATC, SG_ALERT,
                "AI error: updating aircraft without traffic record at " << SG_ORIGIN);
     } else {
@@ -957,7 +957,7 @@ void FGTowerController::signOff(int id)
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id alread has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -968,7 +968,7 @@ void FGTowerController::signOff(int id)
     }
     // If this aircraft has left the runway, we can clear the departure record for this runway
     ActiveRunwayVecIterator rwy = activeRunways.begin();
-    if (activeRunways.size()) {
+    if (! activeRunways.empty()) {
         //while ((rwy->getRunwayName() != i->getRunway()) && (rwy != activeRunways.end())) {
         while (rwy != activeRunways.end()) {
             if (rwy->getRunwayName() == i->getRunway()) {
@@ -984,7 +984,7 @@ void FGTowerController::signOff(int id)
                    "AI error: Attempting to erase non-existing runway clearance record in FGTowerController::signoff at " << SG_ORIGIN);
         }
     }
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || (activeTraffic.empty())) {
         SG_LOG(SG_ATC, SG_ALERT,
                "AI error: Aircraft without traffic record is signing off from tower at " << SG_ORIGIN);
     } else {
@@ -1005,7 +1005,7 @@ bool FGTowerController::hasInstruction(int id)
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1014,7 +1014,7 @@ bool FGTowerController::hasInstruction(int id)
             i++;
         }
     }
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || activeTraffic.empty()) {
         SG_LOG(SG_ATC, SG_ALERT,
                "AI error: checking ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
     } else {
@@ -1029,7 +1029,7 @@ FGATCInstruction FGTowerController::getInstruction(int id)
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1038,7 +1038,7 @@ FGATCInstruction FGTowerController::getInstruction(int id)
             i++;
         }
     }
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || activeTraffic.empty()) {
         SG_LOG(SG_ATC, SG_ALERT,
                "AI error: requesting ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
     } else {
@@ -1084,7 +1084,7 @@ void FGStartupController::announcePosition(int id,
     TrafficVectorIterator i = activeTraffic.begin();
     // Search whether the current id alread has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1094,7 +1094,7 @@ void FGStartupController::announcePosition(int id,
         }
     }
     // Add a new TrafficRecord if no one exsists for this aircraft.
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || activeTraffic.empty()) {
         FGTrafficRecord rec;
         rec.setId(id);
 
@@ -1124,7 +1124,7 @@ bool FGStartupController::hasInstruction(int id)
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1133,7 +1133,7 @@ bool FGStartupController::hasInstruction(int id)
             i++;
         }
     }
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || activeTraffic.empty()) {
         SG_LOG(SG_ATC, SG_ALERT,
                "AI error: checking ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
     } else {
@@ -1148,7 +1148,7 @@ FGATCInstruction FGStartupController::getInstruction(int id)
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1157,7 +1157,7 @@ FGATCInstruction FGStartupController::getInstruction(int id)
             i++;
         }
     }
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || activeTraffic.empty()) {
         SG_LOG(SG_ATC, SG_ALERT,
                "AI error: requesting ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
     } else {
@@ -1171,7 +1171,7 @@ void FGStartupController::signOff(int id)
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id alread has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1180,7 +1180,7 @@ void FGStartupController::signOff(int id)
             i++;
         }
     }
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || activeTraffic.empty()) {
         SG_LOG(SG_ATC, SG_ALERT,
                "AI error: Aircraft without traffic record is signing off from tower at " << SG_ORIGIN);
     } else {
@@ -1230,7 +1230,7 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l
     // Search search if the current id has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
     TrafficVectorIterator current, closest;
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1542,7 +1542,7 @@ void FGApproachController::announcePosition(int id,
     TrafficVectorIterator i = activeTraffic.begin();
     // Search whether the current id alread has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1552,7 +1552,7 @@ void FGApproachController::announcePosition(int id,
         }
     }
     // Add a new TrafficRecord if no one exsists for this aircraft.
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || activeTraffic.empty()) {
         FGTrafficRecord rec;
         rec.setId(id);
 
@@ -1575,7 +1575,7 @@ void FGApproachController::updateAircraftInformation(int id, double lat, double
     // Search search if the current id has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
     TrafficVectorIterator current, closest;
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1585,7 +1585,7 @@ void FGApproachController::updateAircraftInformation(int id, double lat, double
         }
     }
 //    // update position of the current aircraft
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || activeTraffic.empty()) {
         SG_LOG(SG_ATC, SG_ALERT,
                "AI error: updating aircraft without traffic record at " << SG_ORIGIN);
     } else {
@@ -1624,7 +1624,7 @@ void FGApproachController::signOff(int id)
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id alread has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1633,7 +1633,7 @@ void FGApproachController::signOff(int id)
             i++;
         }
     }
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || activeTraffic.empty()) {
         SG_LOG(SG_ATC, SG_ALERT,
                "AI error: Aircraft without traffic record is signing off from approach at " << SG_ORIGIN);
     } else {
@@ -1653,7 +1653,7 @@ bool FGApproachController::hasInstruction(int id)
     TrafficVectorIterator i = activeTraffic.begin();
     // Search search if the current id has an entry
     // This might be faster using a map instead of a vector, but let's start by taking a safe route
-    if (activeTraffic.size()) {
+    if (! activeTraffic.empty()) {
         //while ((i->getId() != id) && i != activeTraffic.end()) {
         while (i != activeTraffic.end()) {
             if (i->getId() == id) {
@@ -1662,7 +1662,7 @@ bool FGApproachController::hasInstruction(int id)
             i++;
         }
     }
-    if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
+    if (i == activeTraffic.end() || activeTraffic.empty()) {
         SG_LOG(SG_ATC, SG_ALERT,
                "AI error: checking ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
     } else {
index 1a137d4a59eaf19f2ab1087a63e33dd26ab3d068..bdedf0e1e902b57d6c45f95ac5794835512ba07c 100644 (file)
@@ -479,7 +479,7 @@ public:
     virtual std::string getName();
     virtual void update(double dt);
     bool hasActiveTraffic() {
-        return activeTraffic.size() != 0;
+        return ! activeTraffic.empty();
     };
     TrafficVector &getActiveTraffic() {
         return activeTraffic;
@@ -516,7 +516,7 @@ public:
     virtual void update(double dt);
 
     bool hasActiveTraffic() {
-        return activeTraffic.size() != 0;
+        return ! activeTraffic.empty();
     };
     TrafficVector &getActiveTraffic() {
         return activeTraffic;
@@ -558,7 +558,7 @@ public:
     ActiveRunway* getRunway(const std::string& name);
 
     bool hasActiveTraffic() {
-        return activeTraffic.size() != 0;
+        return ! activeTraffic.empty();
     };
     TrafficVector &getActiveTraffic() {
         return activeTraffic;
index f483f4f53769ebb2778bd190399eef5126cfa425..30e5bf675eb4a09bcb30a7f0831717614c6ef743 100644 (file)
@@ -572,7 +572,7 @@ FGReplay::record(double time)
 {
     FGReplayData* r = NULL;
 
-    if (recycler.size())
+    if (! recycler.empty())
     {
         r = recycler.front();
         recycler.pop_front();
@@ -588,7 +588,7 @@ void
 FGReplay::interpolate( double time, const replay_list_type &list)
 {
     // sanity checking
-    if ( list.size() == 0 )
+    if ( list.empty() )
     {
         // handle empty list
         return;
@@ -639,7 +639,7 @@ FGReplay::replay( double time ) {
 
     replayMessage(time);
 
-    if ( short_term.size() > 0 ) {
+    if ( ! short_term.empty() ) {
         t1 = short_term.back()->sim_time;
         t2 = short_term.front()->sim_time;
         if ( time > t1 ) {
@@ -649,7 +649,7 @@ FGReplay::replay( double time ) {
             return true;
         } else if ( time <= t1 && time >= t2 ) {
             interpolate( time, short_term );
-        } else if ( medium_term.size() > 0 ) {
+        } else if ( ! medium_term.empty() ) {
             t1 = short_term.front()->sim_time;
             t2 = medium_term.back()->sim_time;
             if ( time <= t1 && time >= t2 )
@@ -660,7 +660,7 @@ FGReplay::replay( double time ) {
                 t2 = medium_term.front()->sim_time;
                 if ( time <= t1 && time >= t2 ) {
                     interpolate( time, medium_term );
-                } else if ( long_term.size() > 0 ) {
+                } else if ( ! long_term.empty() ) {
                     t1 = medium_term.front()->sim_time;
                     t2 = long_term.back()->sim_time;
                     if ( time <= t1 && time >= t2 )
@@ -704,13 +704,13 @@ FGReplay::replay(double time, FGReplayData* pCurrentFrame, FGReplayData* pOldFra
 double
 FGReplay::get_start_time()
 {
-    if ( long_term.size() > 0 )
+    if ( ! long_term.empty() )
     {
         return long_term.front()->sim_time;
-    } else if ( medium_term.size() > 0 )
+    } else if ( ! medium_term.empty() )
     {
         return medium_term.front()->sim_time;
-    } else if ( short_term.size() )
+    } else if ( ! short_term.empty() )
     {
         return short_term.front()->sim_time;
     } else
@@ -722,7 +722,7 @@ FGReplay::get_start_time()
 double
 FGReplay::get_end_time()
 {
-    if ( short_term.size() )
+    if ( ! short_term.empty() )
     {
         return short_term.back()->sim_time;
     } else
index e41db5a590b4845dcedf2976df60fd1601bbb872..5833c02c30aecd55bf014537b0a77899ed54a31a 100644 (file)
@@ -366,7 +366,7 @@ private:
 
     const string& rwy_no_1(token[8]);
     const string& rwy_no_2(token[17]);
-    if ( rwy_no_1.size() == 0 || rwy_no_2.size() == 0 )
+    if ( rwy_no_1.empty() || rwy_no_2.empty() )
         return;
 
     double displ_thresh1 = atof( token[11].c_str() );
index fc658befe287d38fffc9f4bbdac89c3bb6b3a7fa..c111f0995202b2d0b06d30754d50c45dc7bd5859 100644 (file)
@@ -115,7 +115,7 @@ protected:
      * values of &lt;min&gt; and/or &lt;max&gt;. 
      */
     inline double get_output_value() const {
-      return _output_list.size() == 0 ? 0.0 : clamp(_output_list[0]->getDoubleValue());
+      return _output_list.empty() ? 0.0 : clamp(_output_list[0]->getDoubleValue());
     }
 
     simgear::PropertyList _output_list;
@@ -140,7 +140,7 @@ public:
 
 inline void AnalogComponent::disabled( double dt )
 {
-  if( _feedback_if_disabled && _output_list.size() > 0 ) {    
+  if( _feedback_if_disabled && ! _output_list.empty() ) {    
     InputValue * input;
     if( (input = _valueInput.get_active() ) != NULL )
       input->set_value( _output_list[0]->getDoubleValue() );
index fbbadd249eb3e353bd17518401540d04a30c7a96..4cc139996b338471dd601a10531ff0ad8e89281e 100644 (file)
@@ -169,7 +169,7 @@ const FGCommonInput::binding_list_t & FGKeyboardInput::_find_key_bindings (unsig
   FGButton &b = bindings[k];
 
                                 // Try it straight, first.
-  if (b.bindings[modifiers].size() > 0)
+  if (! b.bindings[modifiers].empty())
     return b.bindings[modifiers];
 
                                 // Alt-Gr is CTRL+ALT
index d0f257cc45ac7cf5922fb168c0ef7f1e2d167743..766b0fed17420eebe788b27b13009bccb0b8c49f 100644 (file)
@@ -185,7 +185,7 @@ void HUD::draw(osg::State&)
     if (!isVisible())
         return;
 
-    if (!_items.size() && !_ladders.size())
+    if (_items.empty() && _ladders.empty())
         return;
 
     if (is3D()) {
@@ -321,7 +321,7 @@ void HUD::common_draw()
     _text_list.draw();
     _line_list.draw();
 
-    if (_stipple_line_list.size()) {
+    if (! _stipple_line_list.empty()) {
         glEnable(GL_LINE_STIPPLE);
         glLineStipple(1, 0x00FF);
         _stipple_line_list.draw();
index 22d27d847f0c5fbbffaa679618f8a2b977c05c4a..95066d2ed18caaa3dad615955c238ffa4d014087 100644 (file)
@@ -61,6 +61,7 @@ public:
     void add(const LineSegment& seg) { _list.push_back(seg); }
     void erase() { _list.erase(_list.begin(), _list.end()); }
     inline unsigned int size() const { return _list.size(); }
+    inline bool empty() const { return _list.empty(); }
     void draw() {
         glBegin(GL_LINES);
         std::vector<LineSegment>::const_iterator it, end = _list.end();
index a084fea501dd383541ab1f050efe6752f2f802e5..858869fbd331163823f648f42ba91bf73be1900c 100644 (file)
@@ -587,7 +587,7 @@ void KLN89::DtoPressed() {
                        } else {
                                _dir_page->SetId(_activeWaypoint.id);
                        }
-               } else if(_curPage == 6 && _activePage->GetSubPage() == 3 && fgGetBool("/instrumentation/kln89/scan-pull") && _activeFP->waypoints.size()) {
+               } else if(_curPage == 6 && _activePage->GetSubPage() == 3 && fgGetBool("/instrumentation/kln89/scan-pull") && ! _activeFP->waypoints.empty()) {
                        // NAV 4
                        _dir_page->SetId(((KLN89NavPage*)_activePage)->GetNav4WpId());
                } else if(_curPage == 7 && _activePage->GetSubPage() == 0 && _mode == KLN89_MODE_CRSR) {
@@ -658,7 +658,7 @@ void KLN89::MsgPressed() {
        // TODO - handle persistent messages such as SUA alerting.
        // (The message annunciation flashes before first view, but afterwards remains continuously lit with the message available
        // until the potential conflict no longer pertains).
-       if(_dispMsg && _messageStack.size()) {
+       if(_dispMsg && ! _messageStack.empty()) {
                _messageStack.pop_front();
        }
        _dispMsg = !_dispMsg;
index 405c5a70b28dbb760973ed0496fe5a19c3b3e183..a49fafda864c0ffc2a9936c61272ac8164fc7789 100644 (file)
@@ -97,7 +97,7 @@ typedef gps_waypoint_map::const_iterator gps_waypoint_map_const_iterator;
 class GPSFlightPlan {
 public:
   std::vector<GPSWaypoint*> waypoints;
-       inline bool IsEmpty() { return(waypoints.size() == 0); }
+       inline bool IsEmpty() { return waypoints.empty(); }
 };
 
 // TODO - probably de-public the internals of the next 2 classes and add some methods!
index c1da1dd7bb705ec6ffc7bc09772b37560be04199..9f89dbbb8bdd463375eea844321f6710df3965ef 100644 (file)
@@ -977,7 +977,7 @@ MK_VIII::IOHandler::TerrainClearanceFilter::update (double agl)
 
   // calculate average
   double new_value = 0;
-  if (samples.size() > 0)
+  if (! samples.empty())
     {
       // time consuming loop => queue limited to 75 samples
       // (= 15seconds * 5samples/second)
index 7d4b60f298ba75115ceaf9c09ee15a72024aaaf1..41b606c152bbe3b49702815e98d9bb4693bc5456 100644 (file)
@@ -904,7 +904,7 @@ NavRadioImpl::~NavRadioImpl()
 
 void NavRadioImpl::init()
 {
-  if( 0 < _components.size() )
+  if( ! _components.empty() )
     return;
 
   _components.push_back( new VOR(_rootNode) );
index cdf4f6912bbcbab73630ba97f1d28a7207b8a4e5..1d30dfed0f3d086cd972d7ea1dfce642dd4358b6 100644 (file)
@@ -313,14 +313,14 @@ FGLocale::getLocalizedStrings(const char* id, const char* resource)
         if (_currentLocale)
         {
             simgear::PropertyList s = getLocalizedStrings(_currentLocale, id, resource);
-            if (s.size())
+            if (! s.empty())
                 return s;
         }
 
         if (_defaultLocale)
         {
             simgear::PropertyList s = getLocalizedStrings(_defaultLocale, id, resource);
-            if (s.size())
+            if (! s.empty())
                 return s;
         }
     }
index 31f0a59c7d54c6473c847fa8eb0bd05ab7902f2c..0e8109e0df7b8b6f8b54393d26bd3a487ce0534d 100644 (file)
@@ -50,13 +50,13 @@ FGLogger::init ()
     Log &log = _logs[_logs.size()-1];
     
     string filename = child->getStringValue("filename");
-    if (filename.size() == 0) {
+    if (filename.empty()) {
         filename = "fg_log.csv";
         child->setStringValue("filename", filename.c_str());
     }
 
     string delimiter = child->getStringValue("delimiter");
-    if (delimiter.size() == 0) {
+    if (delimiter.empty()) {
         delimiter = ",";
         child->setStringValue("delimiter", delimiter.c_str());
     }
index e63e6763f95c4d36fe268e6987626a58feb8b727..9158dc89a1ec891d2ec1112003f2c3f44fb76e4a 100644 (file)
@@ -330,7 +330,7 @@ void printReport(SGMetar *m)
                        surface.push_back(buf);
                }
 
-               if (surface.size()) {
+               if (! surface.empty()) {
                        vector<string>::iterator rwysurf = surface.begin();
                        for (i = 0; rwysurf != surface.end(); rwysurf++, i++) {
                                if (i)
index b85ef26b0b87aa0ea74f977d6eef0557e442d46f..70a48decc3184b6f3b66b1f4ddf13e66b90da255 100644 (file)
@@ -1775,7 +1775,7 @@ void Options::init(int argc, char **argv, const SGPath& appDataPath)
   setupRoot();
   
 // system.fgfsrc handling
-  if( hostname.size() > 0 ) {
+  if( ! hostname.empty() ) {
     config.set(globals->get_fg_root());
     config.append( "system.fgfsrc" );
     config.concat( "." );
@@ -2160,7 +2160,7 @@ void Options::showUsage() const
         
         vector<SGPropertyNode_ptr> desc;
         desc = option[k]->getChildren("description");
-        if (desc.size() > 0) {
+        if (! desc.empty()) {
           for ( unsigned int l = 0; l < desc.size(); l++) {
             string t = desc[l]->getStringValue();
 
index d189b917b4ae8a01ab339df184897497a4ca4886..816e997831fcaee8cf0fa37668f94c77a36450c2 100644 (file)
@@ -329,7 +329,7 @@ static bool fgSetPosFromNAV( const string& id, const double& freq, FGPositioned:
   FGNavList::TypeFilter filter(type);
   const nav_list_type navlist = FGNavList::findByIdentAndFreq( id.c_str(), freq, &filter );
   
-  if (navlist.size() == 0 ) {
+  if (navlist.empty()) {
     SG_LOG( SG_GENERAL, SG_ALERT, "Failed to locate NAV = "
            << id << ":" << freq );
     return false;
index 3931a6c8ef50461712dba644b8a6c8b499a057e8..0c92aed912016d803fdaf23a9dfbfd5afacc5600 100644 (file)
@@ -209,7 +209,7 @@ do_reinit (const SGPropertyNode * arg)
     bool result = true;
 
     vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem");
-    if (subsystems.size() == 0) {
+    if (subsystems.empty()) {
         globals->get_subsystem_mgr()->reinit();
     } else {
         for ( unsigned int i = 0; i < subsystems.size(); i++ ) {
index f31484f166a2b97829873ac85a98edcba56cb142..9906701d7ea0ef5117ad6ce5a5b40f38a6000660 100644 (file)
@@ -567,7 +567,7 @@ FGGeneric::reinit()
                 // bad configuration
                 return;
             }
-            if (!binary_mode && (line_separator.size() == 0 ||
+            if (!binary_mode && (line_separator.empty() ||
                 *line_separator.rbegin() != '\n')) {
 
                 SG_LOG(SG_IO, SG_WARN,
index ab4c213b9a77c8eed0343f66292eb989917903a6..e3aaae9f9712fdf2c6d7d0eccf3607443b16942c 100644 (file)
@@ -50,7 +50,7 @@ FGSampleQueue::FGSampleQueue ( SGSoundMgr *smgr, const std::string &refname ) :
 
 FGSampleQueue::~FGSampleQueue ()
 {
-    while ( _messages.size() > 0 ) {
+    while ( ! _messages.empty() ) {
         delete _messages.front();
         _messages.pop();
     }
@@ -92,7 +92,7 @@ FGSampleQueue::update (double dt)
 
         if ( !now_playing ) {
             // message queue idle, add next sound if we have one
-            if ( _messages.size() > 0 ) {
+            if ( ! _messages.empty() ) {
                 SGSampleGroup::add( _messages.front(), msgid );
                 _messages.pop();
                 play_once( msgid );
index 4ad1ed778e69b706c117330a06469f73ba1d89c9..9f793945018bdfe3e27e478e7ec71747437959ae 100644 (file)
@@ -545,7 +545,7 @@ FGScheduledFlight* FGAISchedule::findAvailableFlight (const string &currentDesti
                    continue;
               }
           }
-          if (flights.size()) {
+          if (! flights.empty()) {
             time_t arrival = flights.back()->getArrivalTime();
             int groundTime = groundTimeFromRadius();
             if ((*i)->getDepartureTime() < (arrival+(groundTime)))
index edd2e6ce22621d239463db1f067201fc04bb7a92..ffe10c0e0bb7566b275e613d0c364ea93a57e6ad 100644 (file)
@@ -350,7 +350,7 @@ void fgOSFullScreen()
     std::vector<osgViewer::GraphicsWindow*> windows;
     viewer->getWindows(windows);
 
-    if (windows.size() == 0)
+    if (windows.empty())
         return; // Huh?!?
 
     /* Toggling window fullscreen is only supported for the main GUI window.