From 7d8ccddaaccb4f9ebeaa317ad82aee93ab891399 Mon Sep 17 00:00:00 2001 From: cui Date: Thu, 25 Sep 2025 21:05:27 +0800 Subject: [PATCH] all: refactor to use builtin max/min (#32694) Replaces the last few instances of `math.Max` and `math.Min` with go builtins. --- cmd/utils/flags.go | 3 +-- metrics/runtimehistogram.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c7775adb53..c9da08578c 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -24,7 +24,6 @@ import ( "encoding/json" "errors" "fmt" - "math" "math/big" "net" "net/http" @@ -1620,7 +1619,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { } // Ensure Go's GC ignores the database cache for trigger percentage cache := ctx.Int(CacheFlag.Name) - gogc := math.Max(20, math.Min(100, 100/(float64(cache)/1024))) + gogc := max(20, min(100, 100/(float64(cache)/1024))) log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc)) godebug.SetGCPercent(int(gogc)) diff --git a/metrics/runtimehistogram.go b/metrics/runtimehistogram.go index 0ab8914602..efbed498af 100644 --- a/metrics/runtimehistogram.go +++ b/metrics/runtimehistogram.go @@ -204,7 +204,7 @@ func (h *runtimeHistogramSnapshot) Percentiles(ps []float64) []float64 { thresholds := make([]float64, len(ps)) indexes := make([]int, len(ps)) for i, percentile := range ps { - thresholds[i] = count * math.Max(0, math.Min(1.0, percentile)) + thresholds[i] = count * max(0, min(1.0, percentile)) indexes[i] = i } sort.Sort(floatsAscendingKeepingIndex{thresholds, indexes})