From 44147181c01be6ab012a6e0e9a08819eccc0e007 Mon Sep 17 00:00:00 2001 From: sinamas Date: Wed, 20 Feb 2013 21:05:12 +0100 Subject: [PATCH] common/adaptiveSleep: formatting/readability --- common/adaptivesleep.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/adaptivesleep.cpp b/common/adaptivesleep.cpp index e53b55c2..6bc7e50d 100644 --- a/common/adaptivesleep.cpp +++ b/common/adaptivesleep.cpp @@ -18,6 +18,8 @@ ***************************************************************************/ #include "adaptivesleep.h" +static usec_t absdiff(usec_t a, usec_t b) { return a < b ? b - a : a - b; } + usec_t AdaptiveSleep::sleepUntil(usec_t base, usec_t inc) { usec_t now = getusecs(); usec_t diff = now - base; @@ -35,11 +37,10 @@ usec_t AdaptiveSleep::sleepUntil(usec_t base, usec_t inc) { { usec_t curOversleep = now - ideal; - if (negate(curOversleep) < curOversleep) curOversleep = 0; - oversleepVar = (oversleepVar * 15 + (curOversleep < oversleep ? oversleep - curOversleep : curOversleep - oversleep) + 8) >> 4; + oversleepVar = (oversleepVar * 15 + absdiff(curOversleep, oversleep) + 8) >> 4; oversleep = (oversleep * 15 + curOversleep + 8) >> 4; }