From 9fe3855c3ede2663b0b100a822a82533f6e7ed42 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Mon, 21 Nov 2016 23:55:06 +0100 Subject: [PATCH] dda_queue.c: eliminate a local variable. This shaves off just 2 bytes binary size and saves only one clock cycle for the slowest movement step. But heck, that's better than nothing and comes without drawback, so let's keep this experiment. Performance: ATmega sizes '168 '328(P) '644(P) '1280 Program: 19608 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: 548 clock cycles. LED on time average: 286.252 clock cycles. smooth-curves.gcode statistics: LED on occurences: 23648. LED on time minimum: 272 clock cycles. LED on time maximum: 579 clock cycles. LED on time average: 307.437 clock cycles. triangle-odd.gcode statistics: LED on occurences: 1636. LED on time minimum: 272 clock cycles. LED on time maximum: 538 clock cycles. LED on time average: 297.73 clock cycles. --- dda_queue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dda_queue.c b/dda_queue.c index 3a2c5fc..e97a916 100644 --- a/dda_queue.c +++ b/dda_queue.c @@ -154,12 +154,11 @@ void enqueue_home(TARGET *t, uint8_t endstop_check, uint8_t endstop_stop_cond) { void next_move() { while ((queue_empty() == 0) && (movebuffer[mb_tail].live == 0)) { // next item - uint8_t t = MB_NEXT(mb_tail); - DDA* current_movebuffer = &movebuffer[t]; + 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. - mb_tail = t; if (current_movebuffer->waitfor_temp) { serial_writestr_P(PSTR("Waiting for target temp\n")); current_movebuffer->live = 1;