Minor optimization of handling the timers
Mathias Gumz akira at fluxbox dot org
1 files changed,
15 insertions(+),
15 deletions(-)
jump to
M
src/FbTk/Timer.cc
→
src/FbTk/Timer.cc
@@ -200,31 +200,31 @@ // stoping / restarting the timers modifies the list in an upredictable
// way. to avoid problems such as infinite loops we save the current // (ordered) list of timers into a list and work on it. - ssize_t i; - const ssize_t ts = s_timerlist.size(); - std::vector<FbTk::Timer*> timers; + static std::vector<FbTk::Timer*> timeouts; - timers.reserve(ts); + now = FbTime::now(); for (it = s_timerlist.begin(); it != s_timerlist.end(); ++it ) { - timers.push_back(*it); + if (now < (*it)->getEndTime()) { + break; + } + timeouts.push_back(*it); } - now = FbTime::now(); + size_t i; + const size_t ts = timeouts.size(); for (i = 0; i < ts; ++i) { - FbTk::Timer* t = timers[i]; + FbTk::Timer& t = *timeouts[i]; - if (now < t->getEndTime()) { - break; - } + t.fireTimeout(); + t.stop(); - t->fireTimeout(); - t->stop(); - - if (! t->doOnce()) { // restart the current timer - t->start(); + if (! t.doOnce()) { // restart the current timer + t.start(); } } + + timeouts.clear(); }