diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2013-01-13 11:23:06 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2013-01-13 11:23:06 (GMT) |
commit | 13b9ee09ee1a8d2423baa0f4f84f5509e389023a (patch) | |
tree | f02957d42d1905796b0dbba4fd71f45b9129197d | |
parent | 4d307dcd10af9d817ff5c05fc40ae7487564cb31 (diff) | |
download | fluxbox-13b9ee09ee1a8d2423baa0f4f84f5509e389023a.zip fluxbox-13b9ee09ee1a8d2423baa0f4f84f5509e389023a.tar.bz2 |
Minor optimization of handling the timers
-rw-r--r-- | src/FbTk/Timer.cc | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/FbTk/Timer.cc b/src/FbTk/Timer.cc index dd736dd..eff3af4 100644 --- a/src/FbTk/Timer.cc +++ b/src/FbTk/Timer.cc | |||
@@ -200,31 +200,31 @@ void Timer::updateTimers(int fd) { | |||
200 | // way. to avoid problems such as infinite loops we save the current | 200 | // way. to avoid problems such as infinite loops we save the current |
201 | // (ordered) list of timers into a list and work on it. | 201 | // (ordered) list of timers into a list and work on it. |
202 | 202 | ||
203 | ssize_t i; | 203 | static std::vector<FbTk::Timer*> timeouts; |
204 | const ssize_t ts = s_timerlist.size(); | ||
205 | std::vector<FbTk::Timer*> timers; | ||
206 | 204 | ||
207 | timers.reserve(ts); | 205 | now = FbTime::now(); |
208 | for (it = s_timerlist.begin(); it != s_timerlist.end(); ++it ) { | 206 | for (it = s_timerlist.begin(); it != s_timerlist.end(); ++it ) { |
209 | timers.push_back(*it); | 207 | if (now < (*it)->getEndTime()) { |
208 | break; | ||
209 | } | ||
210 | timeouts.push_back(*it); | ||
210 | } | 211 | } |
211 | 212 | ||
212 | now = FbTime::now(); | 213 | size_t i; |
214 | const size_t ts = timeouts.size(); | ||
213 | for (i = 0; i < ts; ++i) { | 215 | for (i = 0; i < ts; ++i) { |
214 | 216 | ||
215 | FbTk::Timer* t = timers[i]; | 217 | FbTk::Timer& t = *timeouts[i]; |
216 | 218 | ||
217 | if (now < t->getEndTime()) { | 219 | t.fireTimeout(); |
218 | break; | 220 | t.stop(); |
219 | } | ||
220 | 221 | ||
221 | t->fireTimeout(); | 222 | if (! t.doOnce()) { // restart the current timer |
222 | t->stop(); | 223 | t.start(); |
223 | |||
224 | if (! t->doOnce()) { // restart the current timer | ||
225 | t->start(); | ||
226 | } | 224 | } |
227 | } | 225 | } |
226 | |||
227 | timeouts.clear(); | ||
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||