From 721649e8ef5315847556f4f3e07af06215eaa437 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Tue, 22 Nov 2016 00:16:21 +0100 Subject: [PATCH] dda_queue.c: eliminate another local variable. This shaves off another 3 clock cycles without drawback. It increases binary size by 8 bytes, but apparently only in places where it doesn't matter. Performance: ATmega sizes '168 '328(P) '644(P) '1280 Program: 19616 bytes 137% 64% 31% 16% Data: 2175 bytes 213% 107% 54% 27% EEPROM: 32 bytes 4% 2% 2% 1% short-moves.gcode statistics: LED on occurences: 888. LED on time minimum: 280 clock cycles. LED on time maximum: 545 clock cycles. LED on time average: 286.187 clock cycles. smooth-curves.gcode statistics: LED on occurences: 23648. LED on time minimum: 272 clock cycles. LED on time maximum: 576 clock cycles. LED on time average: 307.431 clock cycles. triangle-odd.gcode statistics: LED on occurences: 1636. LED on time minimum: 272 clock cycles. LED on time maximum: 535 clock cycles. LED on time average: 297.724 clock cycles. --- dda_queue.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dda_queue.c b/dda_queue.c index e97a916..05d566f 100644 --- a/dda_queue.c +++ b/dda_queue.c @@ -153,19 +153,18 @@ void enqueue_home(TARGET *t, uint8_t endstop_check, uint8_t endstop_stop_cond) { /// timer interrupt is disabled). void next_move() { while ((queue_empty() == 0) && (movebuffer[mb_tail].live == 0)) { - // next item - mb_tail = MB_NEXT(mb_tail); - DDA* current_movebuffer = &movebuffer[mb_tail]; // Tail must be set before calling timer_set(), as timer_set() reenables // the timer interrupt, potentially exposing mb_tail to the timer // interrupt routine. - if (current_movebuffer->waitfor_temp) { + mb_tail = MB_NEXT(mb_tail); + + if (movebuffer[mb_tail].waitfor_temp) { serial_writestr_P(PSTR("Waiting for target temp\n")); - current_movebuffer->live = 1; + movebuffer[mb_tail].live = 1; timer_set(HEATER_WAIT_TIMEOUT, 0); } else { - dda_start(current_movebuffer); + dda_start(&movebuffer[mb_tail]); } } }