From 4a86650120885de052f985ccc39ddf441a9f6ac3 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Sun, 21 Sep 2025 22:30:22 +0800 Subject: [PATCH] all: refactor to use builtin max/min --- 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 5e96185dbd0..d186c5b8c0a 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" @@ -1610,7 +1609,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 0ab89146026..efbed498af8 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})