FIXME: Suboptimal */
| 217 | |
| 218 | /* FIXME: Suboptimal */ |
| 219 | static const struct timer *brute_force_first(struct timers *timers) |
| 220 | { |
| 221 | unsigned int l, i; |
| 222 | const struct timer *found = NULL; |
| 223 | |
| 224 | for (l = 0; l < ARRAY_SIZE(timers->level) && timers->level[l]; l++) { |
| 225 | const struct timer *t = NULL; |
| 226 | |
| 227 | /* Do we know they don't have a better one? */ |
| 228 | if (!level_may_beat(timers, l, found)) |
| 229 | continue; |
| 230 | |
| 231 | /* Find first timer on this level. */ |
| 232 | for (i = 0; i < PER_LEVEL; i++) |
| 233 | t = find_first(&timers->level[l]->list[i], l, t); |
| 234 | |
| 235 | found = first_for_level(timers, l, t, found); |
| 236 | } |
| 237 | |
| 238 | /* Check (and update) far list if there's a chance. */ |
| 239 | l = ARRAY_SIZE(timers->level); |
| 240 | if (level_may_beat(timers, l, found)) { |
| 241 | const struct timer *t = find_first(&timers->far, l, NULL); |
| 242 | found = first_for_level(timers, l, t, found); |
| 243 | } |
| 244 | |
| 245 | return found; |
| 246 | } |
| 247 | |
| 248 | static const struct timer *get_first(struct timers *timers) |
| 249 | { |
no test coverage detected