]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Simplify expression used in frequency accumulation
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 9 Jan 2014 17:17:57 +0000 (18:17 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 9 Jan 2014 17:31:35 +0000 (18:31 +0100)
local.c
rtc_linux.c

diff --git a/local.c b/local.c
index e4be12b6306872906b2c71f3324aae20c92f28b7..9276ee52f1d9492de7d2bfac8f0ce03badfd7deb 100644 (file)
--- a/local.c
+++ b/local.c
@@ -411,7 +411,7 @@ LCL_AccumulateDeltaFrequency(double dfreq)
    are handled in units of ppm, whereas the 'dfreq' argument is in
    terms of the gradient of the (offset) v (local time) function. */
 
-  current_freq_ppm = (1.0 - dfreq) * current_freq_ppm + 1.0e6 * dfreq;
+  current_freq_ppm += dfreq * (1.0e6 - current_freq_ppm);
 
   /* Call the system-specific driver for setting the frequency */
   current_freq_ppm = (*drv_set_freq)(current_freq_ppm);
@@ -508,7 +508,7 @@ LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset, double corr_rate)
   /* Work out new absolute frequency.  Note that absolute frequencies
    are handled in units of ppm, whereas the 'dfreq' argument is in
    terms of the gradient of the (offset) v (local time) function. */
-  current_freq_ppm = (1.0 - dfreq) * old_freq_ppm + 1.0e6 * dfreq;
+  current_freq_ppm += dfreq * (1.0e6 - current_freq_ppm);
 
   DEBUG_LOG(LOGF_Local, "old_freq=%.3fppm new_freq=%.3fppm offset=%.6fsec",
       old_freq_ppm, current_freq_ppm, doffset);
index 3fcf29765321bb5e7e94b017051f408c6277b4b9..8eda9063210e52b9466359d87d71b1ffbed1c79a 100644 (file)
@@ -282,7 +282,7 @@ slew_samples
 
   if (coefs_valid) {
     coef_seconds_fast += doffset;
-    coef_gain_rate = (1.0 - dfreq) * coef_gain_rate + dfreq;
+    coef_gain_rate += dfreq * (1.0 - coef_gain_rate);
   }
 
   DEBUG_LOG(LOGF_RtcLinux, "dfreq=%.8f doffset=%.6f old_fast=%.6f old_rate=%.3f new_fast=%.6f new_rate=%.3f",