diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2022-03-05 20:49:26 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2022-03-05 20:49:26 +0000 |
commit | d753ba5f49a061464c90b46de852944fe5fe3763 (patch) | |
tree | 7f334774dc30c8b224a69169a093c488fcf48df3 /src/rspamd.c | |
parent | 0b4e9a4f0b3bfa7d3bc3a40239b41d85a15a44be (diff) | |
download | rspamd-d753ba5f49a061464c90b46de852944fe5fe3763.tar.gz rspamd-d753ba5f49a061464c90b46de852944fe5fe3763.zip |
[Minor] Deduplicate sum function
Diffstat (limited to 'src/rspamd.c')
-rw-r--r-- | src/rspamd.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/rspamd.c b/src/rspamd.c index d1eaa205d..610c9aa7b 100644 --- a/src/rspamd.c +++ b/src/rspamd.c @@ -1107,20 +1107,8 @@ rspamd_stat_update_handler (struct ev_loop *loop, ev_timer *w, int revents) cur_stat.actions_stat[METRIC_ACTION_REWRITE_SUBJECT]; gdouble new_ham = cur_stat.actions_stat[METRIC_ACTION_NOACTION]; - /* Kahan sum */ - float sum = 0.0f; - volatile float c = 0.0f; /* We don't want any optimisations around c */ - int cnt = 0; - - for (int i = 0; i < MAX_AVG_TIME_SLOTS; i ++) { - if (!isnan(cur_stat.avg_time.avg_time[i])) { - cnt ++; - float y = cur_stat.avg_time.avg_time[i] - c; - float t = sum + y; - c = (t - sum) - y; - sum = t; - } - } + gsize cnt = MAX_AVG_TIME_SLOTS; + float sum = rspamd_sum_floats (cur_stat.avg_time.avg_time, &cnt); rspamd_snprintf (proctitle, sizeof (proctitle), "main process; %.1f msg/sec, %.1f msg/sec spam, %.1f msg/sec ham; %.2fs avg processing time", |