From 026b9c336ce6f219d9b3c695450acadb2192ce20 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 31 Aug 2017 10:07:44 -0400 Subject: [PATCH] stepcompress: Minor performance tweaks for rpi Invert the if conditional in queue_append() and change the order of reads in minmax_point() - gcc on the rpi seems to do generate better code this way. Signed-off-by: Kevin O'Connor --- klippy/stepcompress.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c index b4d2dc2a..c3f010b2 100644 --- a/klippy/stepcompress.c +++ b/klippy/stepcompress.c @@ -66,9 +66,8 @@ struct points { static inline struct points minmax_point(struct stepcompress *sc, uint32_t *pos) { - uint32_t lsc = sc->last_step_clock; + uint32_t lsc = sc->last_step_clock, point = *pos - lsc; uint32_t prevpoint = pos > sc->queue_pos ? *(pos-1) - lsc : 0; - uint32_t point = *pos - lsc; uint32_t max_error = (point - prevpoint) / 2; if (max_error > sc->max_error) max_error = sc->max_error; @@ -443,7 +442,7 @@ static inline int queue_append(struct queue_append *qa, double step_clock) { double rel_sc = step_clock + qa->clock_offset; - if (likely(qa->qnext < qa->qend && rel_sc < (double)CLOCK_DIFF_MAX)) { + if (likely(!(qa->qnext >= qa->qend || rel_sc >= (double)CLOCK_DIFF_MAX))) { *qa->qnext++ = qa->last_step_clock_32 + (uint32_t)rel_sc; return 0; }