all repos — fluxbox @ 13b9ee09ee1a8d2423baa0f4f84f5509e389023a

custom fork of the fluxbox windowmanager

Minor optimization of handling the timers
Mathias Gumz akira at fluxbox dot org
commit

13b9ee09ee1a8d2423baa0f4f84f5509e389023a

parent

4d307dcd10af9d817ff5c05fc40ae7487564cb31

1 files changed, 15 insertions(+), 15 deletions(-)

jump to
M src/FbTk/Timer.ccsrc/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(); }