Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74816 - trunk/boost/asio/detail
From: chris_at_[hidden]
Date: 2011-10-08 17:08:39


Author: chris_kohlhoff
Date: 2011-10-08 17:08:39 EDT (Sat, 08 Oct 2011)
New Revision: 74816
URL: http://svn.boost.org/trac/boost/changeset/74816

Log:
Don't read the clock unless the heap is non-empty.
Text files modified:
   trunk/boost/asio/detail/timer_queue.hpp | 13 ++++++++-----
   1 files changed, 8 insertions(+), 5 deletions(-)

Modified: trunk/boost/asio/detail/timer_queue.hpp
==============================================================================
--- trunk/boost/asio/detail/timer_queue.hpp (original)
+++ trunk/boost/asio/detail/timer_queue.hpp 2011-10-08 17:08:39 EDT (Sat, 08 Oct 2011)
@@ -159,12 +159,15 @@
   // Dequeue all timers not later than the current time.
   virtual void get_ready_timers(op_queue<operation>& ops)
   {
- const time_type now = Time_Traits::now();
- while (!heap_.empty() && !Time_Traits::less_than(now, heap_[0].time_))
+ if (!heap_.empty())
     {
- per_timer_data* timer = heap_[0].timer_;
- ops.push(timer->op_queue_);
- remove_timer(*timer);
+ const time_type now = Time_Traits::now();
+ while (!heap_.empty() && !Time_Traits::less_than(now, heap_[0].time_))
+ {
+ per_timer_data* timer = heap_[0].timer_;
+ ops.push(timer->op_queue_);
+ remove_timer(*timer);
+ }
     }
   }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk