From d2d3bd00297c769a45714e726c7c6f82f467e029 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Wed, 17 Jul 2019 15:22:45 +0200 Subject: [PATCH] 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. --- pdns/syncres.hh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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; } -- 2.47.2