From: Otto Moerbeek Date: Wed, 17 Jul 2019 13:22:45 +0000 (+0200) Subject: Some unneeded float<->double conversions. X-Git-Tag: dnsdist-1.4.0-rc2~30^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2d3bd00297c769a45714e726c7c6f82f467e029;p=thirdparty%2Fpdns.git Some unneeded float<->double conversions. Note that float saves mem, but on some machines it might even be slower than double, since most FPUs are optimized for double. --- diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 1d6ef2d2c7..b009d5ed36 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -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; }