From fe985a18d3df0a6c1cc92ed4fa602fe812642980 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Fri, 25 Oct 2013 12:55:54 +0200 Subject: [PATCH] dda_lookahead.c: simplify bailout condition tests. We have the nullmove flag already and the current move can't be a nullmove, because in this case we wouldn't enter the function. --- dda.c | 2 +- dda_lookahead.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dda.c b/dda.c index b83115b..1961ca2 100644 --- a/dda.c +++ b/dda.c @@ -382,7 +382,7 @@ void dda_create(DDA *dda, TARGET *target, DDA *prev_dda) { if (dda->c < c_limit) dda->c = c_limit; #endif - } + } /* ! dda->total_steps == 0 */ if (DEBUG_DDA && (debug_flags & DEBUG_DDA)) serial_writestr_P(PSTR("] }\n")); diff --git a/dda_lookahead.c b/dda_lookahead.c index 6ae416f..3e20a63 100644 --- a/dda_lookahead.c +++ b/dda_lookahead.c @@ -185,9 +185,9 @@ void dda_join_moves(DDA *prev, DDA *current) { moveno++; #endif - // Sanity: if the previous move or this one has no actual movement, bail now. (e.g. G1 F1500) - if(prev->delta.X==0 && prev->delta.Y==0 && prev->delta.Z==0 && prev->delta.E==0) return; - if(current->delta.X==0 && current->delta.Y==0 && current->delta.Z==0 && current->delta.E==0) return; + // Bail out if there's nothing to join (e.g. G1 F1500). + if ( ! prev || prev->nullmove) + return; serprintf(PSTR("Current Delta: %ld,%ld,%ld E:%ld Live:%d\r\n"), current->delta.X, current->delta.Y, current->delta.Z, current->delta.E, current->live); serprintf(PSTR("Prev Delta: %ld,%ld,%ld E:%ld Live:%d\r\n"), prev->delta.X, prev->delta.Y, prev->delta.Z, prev->delta.E, prev->live); @@ -196,7 +196,7 @@ void dda_join_moves(DDA *prev, DDA *current) { // Note: moves are only modified after the calculations are complete. // Only prepare for look-ahead if we have 2 available moves to // join and the Z axis is unused (for now, Z axis moves are NOT joined). - if(prev!=NULL && prev->live==0 && prev->delta.Z==current->delta.Z) { + if (prev->live == 0 && prev->delta.Z == current->delta.Z) { // Calculate the jerk if the previous move and this move would be joined // together at full speed. jerk = dda_jerk_size_2d(prev->delta.X, prev->delta.Y, prev->endpoint.F, @@ -210,7 +210,7 @@ void dda_join_moves(DDA *prev, DDA *current) { } // Make sure we have 2 moves and the previous move is not already active - if(prev!=NULL && prev->live==0) { + if (prev->live == 0) { // Perform an atomic copy to preserve volatile parameters during the calculations ATOMIC_START prev_id = prev->id;