summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/hash.c9
-rw-r--r--lib/hash.h4
2 files changed, 4 insertions, 9 deletions
diff --git a/lib/hash.c b/lib/hash.c
index 62a39953c..bdb2e097c 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -87,13 +87,8 @@ hash_alloc_intern (void *arg)
}
#define hash_update_ssq(hz, old, new) \
- do { \
- long double res; \
- res = powl(old, 2.0); \
- hz->stats.ssq -= (uint64_t) res;\
- res = powl(new, 2.0); \
- hz->stats.ssq += (uint64_t) res; \
- } while (0); \
+ atomic_fetch_add_explicit(&hz->stats.ssq, (new + old)*(new - old),\
+ memory_order_relaxed);
/* Expand hash if the chain length exceeds the threshold. */
static void hash_expand (struct hash *hash)
diff --git a/lib/hash.h b/lib/hash.h
index 01d2b1ddc..3b2671afa 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -53,9 +53,9 @@ struct hash_backet
struct hashstats
{
/* number of empty hash buckets */
- _Atomic int empty;
+ _Atomic uint_fast32_t empty;
/* sum of squares of bucket length */
- _Atomic uint64_t ssq;
+ _Atomic uint_fast32_t ssq;
};
struct hash