Express binCount using integer operations.

No need to bring a float64 into this.
This commit is contained in:
David Fifield 2025-08-15 17:30:21 +00:00
parent 70974640ab
commit b058b10a94

View file

@ -8,7 +8,6 @@ package main
import ( import (
"fmt" "fmt"
"log" "log"
"math"
"net" "net"
"sort" "sort"
"sync" "sync"
@ -276,9 +275,10 @@ func (m *Metrics) printMetrics() {
m.logger.Println("snowflake-ips-nat-unknown", m.loadAndZero("proxy-nat-unknown")) 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 { func binCount(count uint64) uint64 {
return uint64((math.Ceil(float64(count) / 8)) * 8) return (count + 7) / 8 * 8
} }
type PromMetrics struct { type PromMetrics struct {