From 6ab269ceb776057a6d99850dc0fa47c7345faaa2 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 14 Nov 2016 15:36:11 -0500 Subject: [PATCH] stepcompress: Don't bother loop unrolling in push_sqrt() It's not necessary to have two loops - checking if factor is greater than zero in the loop is fine. Signed-off-by: Kevin O'Connor --- klippy/stepcompress.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c index afd9886b..b00dd7c3 100644 --- a/klippy/stepcompress.c +++ b/klippy/stepcompress.c @@ -419,16 +419,11 @@ stepcompress_push_sqrt(struct stepcompress *sc, double steps, double step_offset uint64_t *qn = sc->queue_next, *end = &qn[count]; clock_offset += 0.5; double pos = step_offset + .5 + sqrt_offset/factor; - if (factor >= 0.0) - while (qn < end) { - *qn++ = clock_offset + safe_sqrt(pos*factor); - pos += 1.0; - } - else - while (qn < end) { - *qn++ = clock_offset - safe_sqrt(pos*factor); - pos += 1.0; - } + while (qn < end) { + double v = safe_sqrt(pos*factor); + *qn++ = clock_offset + (factor >= 0. ? v : -v); + pos += 1.0; + } sc->queue_next = qn; return sdir ? count : -count; }