commit 0b7a4e7: [Minor] Use float instead of double

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jul 14 18:42:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-07-14 19:38:31 +0100
URL: https://github.com/rspamd/rspamd/commit/0b7a4e77fe205edf95e020471d222eb64c05e502

[Minor] Use float instead of double

---
 src/libutil/util.c | 10 +++++-----
 src/libutil/util.h | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/libutil/util.c b/src/libutil/util.c
index 16c8c0f23..8bbc98993 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -2422,12 +2422,12 @@ rspamd_set_counter (struct rspamd_counter_data *cd, gdouble value)
 	return cd->mean;
 }
 
-double
+float
 rspamd_set_counter_ema (struct rspamd_counter_data *cd,
-		gdouble value,
-		gdouble alpha)
+		float value,
+		float alpha)
 {
-	gdouble diff, incr;
+	float diff, incr;
 
 	/* Cumulative moving average using per-process counter data */
 	if (cd->number == 0) {
@@ -2438,7 +2438,7 @@ rspamd_set_counter_ema (struct rspamd_counter_data *cd,
 	diff = value - cd->mean;
 	incr = diff * alpha;
 	cd->mean += incr;
-	cd->stddev = (1 - alpha) * (cd->stddev + diff * incr);
+	cd->stddev = (1.0f - alpha) * (cd->stddev + diff * incr);
 	cd->number ++;
 
 	return cd->mean;
diff --git a/src/libutil/util.h b/src/libutil/util.h
index d993fcbdf..f3ff94fdd 100644
--- a/src/libutil/util.h
+++ b/src/libutil/util.h
@@ -468,8 +468,8 @@ GPtrArray *rspamd_glob_path (const gchar *dir,
 							 GError **err);
 
 struct rspamd_counter_data {
-	gdouble mean;
-	gdouble stddev;
+	float mean;
+	float stddev;
 	guint64 number;
 };
 
@@ -480,9 +480,9 @@ struct rspamd_counter_data {
  * @param alpha decay coefficient (0..1)
  * @return new counter value
  */
-double rspamd_set_counter_ema (struct rspamd_counter_data *cd,
-							   gdouble value,
-							   gdouble alpha);
+float rspamd_set_counter_ema (struct rspamd_counter_data *cd,
+							   float value,
+							   float alpha);
 
 /**
  * Sets counter's data using flat moving average


More information about the Commits mailing list