From b058b10a945bc7a2711487eefe227380761fcbd7 Mon Sep 17 00:00:00 2001 From: David Fifield Date: Fri, 15 Aug 2025 17:30:21 +0000 Subject: [PATCH] Express binCount using integer operations. No need to bring a float64 into this. --- broker/metrics.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/broker/metrics.go b/broker/metrics.go index 99779b9..b40a898 100644 --- a/broker/metrics.go +++ b/broker/metrics.go @@ -8,7 +8,6 @@ package main import ( "fmt" "log" - "math" "net" "sort" "sync" @@ -276,9 +275,10 @@ func (m *Metrics) printMetrics() { m.logger.Println("snowflake-ips-nat-unknown", m.loadAndZero("proxy-nat-unknown")) } -// Rounds up a count to the nearest multiple of 8. +// binCount rounds count up to the next multiple of 8. Returns 0 on integer +// overflow. func binCount(count uint64) uint64 { - return uint64((math.Ceil(float64(count) / 8)) * 8) + return (count + 7) / 8 * 8 } type PromMetrics struct {