]> oss.titaniummirror.com Git - rgblamp.git/blobdiff - task.c
Don't use % to rotate _task_bitno; too slow.
[rgblamp.git] / task.c
diff --git a/task.c b/task.c
index 26a0b46a626f71e44a0db5135ed0a91aeaa38202..bce2b6dbaf30e59a4b3bb7ab25dfe75a3c02ede3 100644 (file)
--- a/task.c
+++ b/task.c
@@ -38,7 +38,8 @@ task_id_t task_get(unsigned char block)
       for (unsigned char i = 0; t == -1 && i < TASK_COUNT; i++) {
         if (bit_get(ids, _task_bitno))
           t = _task_bitno;
-        _task_bitno = (_task_bitno + 1) % TASK_COUNT;
+        if (++_task_bitno == TASK_COUNT)
+          _task_bitno = 0;
       }
     }
 #if 0 /* Not until we have a crystal and can wake from sleep via tmr module */
@@ -46,7 +47,7 @@ task_id_t task_get(unsigned char block)
       SLEEP();
 #endif
   } while (t == -1 && block == 1);
-  if (t) {
+  if (t >= 0) {
     ndi();
     bit_clr(_task_ids, t);
     nei();