From 35c5be004fe93652850411c6fe3dbe4f9d57ae81 Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 2 Sep 2018 19:56:26 +0100 Subject: [PATCH] Reduce CPU hit in FGTaxiSegment::unblock size() is O(N), empty() is constant time. --- src/Airports/groundnetwork.cxx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Airports/groundnetwork.cxx b/src/Airports/groundnetwork.cxx index 36947dfb7..51b96c82a 100644 --- a/src/Airports/groundnetwork.cxx +++ b/src/Airports/groundnetwork.cxx @@ -121,16 +121,14 @@ bool FGTaxiSegment::hasBlock(time_t now) void FGTaxiSegment::unblock(time_t now) { - if (blockTimes.size()) { - BlockListIterator i = blockTimes.begin(); - if (i->getTimeStamp() < (now - 30)) { - blockTimes.erase(i); - } + if (blockTimes.empty()) + return; + + if (blockTimes.front().getTimeStamp() < (now - 30)) { + blockTimes.erase(blockTimes.begin()); } } - - /*************************************************************************** * FGTaxiRoute **************************************************************************/