]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use float instead of double
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 14 Jul 2021 18:38:31 +0000 (19:38 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 14 Jul 2021 18:38:31 +0000 (19:38 +0100)
src/libutil/util.c
src/libutil/util.h

index 16c8c0f23f56e700669ca42850b6f90e761f3209..8bbc9899337eb07ecb9249fa10bc63da9cd7e59e 100644 (file)
@@ -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;
index d993fcbdfc44cb2af3eb4fe106bf8abd70a21f6d..f3ff94fdd8fb7dac4611b0f5f789d4dd0f241054 100644 (file)
@@ -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