main: Replace MOD with bitwise AND
This prevents `moduint` from being called for the superloop. A bitwise AND is used instead of using the equivalent `% 4` as an indication that modulo should not be used, as not using a power of 2 (which is optimized) will result in an expensive call to SDCC library functions. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Tim Crawford
parent
766fb738a0
commit
4b86176659
@ -102,7 +102,7 @@ void main(void) {
|
|||||||
uint32_t last_time_fan = 0;
|
uint32_t last_time_fan = 0;
|
||||||
|
|
||||||
for (main_cycle = 0;; main_cycle++) {
|
for (main_cycle = 0;; main_cycle++) {
|
||||||
switch (main_cycle % 3U) {
|
switch (main_cycle & 3U) {
|
||||||
case 0:
|
case 0:
|
||||||
// Handle USB-C events immediately before power states
|
// Handle USB-C events immediately before power states
|
||||||
usbpd_event();
|
usbpd_event();
|
||||||
@ -123,6 +123,11 @@ void main(void) {
|
|||||||
// Handle lid close/open
|
// Handle lid close/open
|
||||||
lid_event();
|
lid_event();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
// We previously used modulo to limit when the logic for other
|
||||||
|
// cases ran, so this case is unused.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (main_cycle == 0) {
|
if (main_cycle == 0) {
|
||||||
|
Reference in New Issue
Block a user