aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-07-14 19:38:31 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-07-14 19:38:31 +0100
commit0b7a4e77fe205edf95e020471d222eb64c05e502 (patch)
treec9065d621df3e600c59bf57e26c1fc7c1d6aff32 /src
parent8d6010f86f77c07645319ddca16bd3000f0dcca6 (diff)
downloadrspamd-0b7a4e77fe205edf95e020471d222eb64c05e502.tar.gz
rspamd-0b7a4e77fe205edf95e020471d222eb64c05e502.zip
[Minor] Use float instead of double
Diffstat (limited to 'src')
-rw-r--r--src/libutil/util.c10
-rw-r--r--src/libutil/util.h10
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