mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-15 12:36:48 +00:00
all: refactor to use builtin max/min (#32694)
Replaces the last few instances of `math.Max` and `math.Min` with go builtins.
This commit is contained in:
parent
bacc1504ba
commit
7d8ccddaac
2 changed files with 2 additions and 3 deletions
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"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
|
// Ensure Go's GC ignores the database cache for trigger percentage
|
||||||
cache := ctx.Int(CacheFlag.Name)
|
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))
|
log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc))
|
||||||
godebug.SetGCPercent(int(gogc))
|
godebug.SetGCPercent(int(gogc))
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ func (h *runtimeHistogramSnapshot) Percentiles(ps []float64) []float64 {
|
||||||
thresholds := make([]float64, len(ps))
|
thresholds := make([]float64, len(ps))
|
||||||
indexes := make([]int, len(ps))
|
indexes := make([]int, len(ps))
|
||||||
for i, percentile := range 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
|
indexes[i] = i
|
||||||
}
|
}
|
||||||
sort.Sort(floatsAscendingKeepingIndex{thresholds, indexes})
|
sort.Sort(floatsAscendingKeepingIndex{thresholds, indexes})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue