Skip to content

Commit 7d8ccdd

Browse files
authored
all: refactor to use builtin max/min (#32694)
Replaces the last few instances of `math.Max` and `math.Min` with go builtins.
1 parent bacc150 commit 7d8ccdd

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

cmd/utils/flags.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"encoding/json"
2525
"errors"
2626
"fmt"
27-
"math"
2827
"math/big"
2928
"net"
3029
"net/http"
@@ -1620,7 +1619,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
16201619
}
16211620
// Ensure Go's GC ignores the database cache for trigger percentage
16221621
cache := ctx.Int(CacheFlag.Name)
1623-
gogc := math.Max(20, math.Min(100, 100/(float64(cache)/1024)))
1622+
gogc := max(20, min(100, 100/(float64(cache)/1024)))
16241623

16251624
log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc))
16261625
godebug.SetGCPercent(int(gogc))

metrics/runtimehistogram.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func (h *runtimeHistogramSnapshot) Percentiles(ps []float64) []float64 {
204204
thresholds := make([]float64, len(ps))
205205
indexes := make([]int, len(ps))
206206
for i, percentile := range ps {
207-
thresholds[i] = count * math.Max(0, math.Min(1.0, percentile))
207+
thresholds[i] = count * max(0, min(1.0, percentile))
208208
indexes[i] = i
209209
}
210210
sort.Sort(floatsAscendingKeepingIndex{thresholds, indexes})

0 commit comments

Comments
 (0)