]> granicus.if.org Git - pdns/commitdiff
Some unneeded float<->double conversions.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 17 Jul 2019 13:22:45 +0000 (15:22 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 17 Jul 2019 13:33:16 +0000 (15:33 +0200)
Note that float saves mem, but on some machines it might even be
slower than double, since most FPUs are optimized for double.

pdns/syncres.hh

index 1d6ef2d2c71e48fbd3b725e58b141cb9a09110cf..b009d5ed369147276ab662e804a2f1a50ff6f983 100644 (file)
@@ -181,21 +181,21 @@ public:
       float diff= makeFloat(d_last - now);
 
       d_last=now;
-      double factor=exp(diff)/2.0; // might be '0.5', or 0.0001
-      d_val=(float)((1-factor)*val+ (float)factor*d_val);
+      float factor=expf(diff)/2.0f; // might be '0.5', or 0.0001
+      d_val=(1-factor)*val + factor*d_val;
     }
   }
 
-  double get(const struct timeval* tv)
+  float get(const struct timeval* tv)
   {
     struct timeval now=*tv;
     float diff=makeFloat(d_lastget-now);
     d_lastget=now;
-    float factor=exp(diff/60.0f); // is 1.0 or less
+    float factor=expf(diff/60.0f); // is 1.0 or less
     return d_val*=factor;
   }
 
-  double peek(void) const
+  float peek(void) const
   {
     return d_val;
   }