mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
Update metrics.go
Pre-allocate bucketsCounter slice with make() to avoid multiple reallocations during initialization. This matches the pattern used elsewhere in the codebase and eliminates unnecessary memory allocations for the 17-element slice.
This commit is contained in:
parent
2e5cd21edf
commit
1d2accd2f4
1 changed files with 2 additions and 1 deletions
|
|
@ -40,8 +40,9 @@ var (
|
|||
)
|
||||
|
||||
func init() {
|
||||
bucketsCounter = make([]*metrics.Counter, nBuckets)
|
||||
for i := 0; i < nBuckets; i++ {
|
||||
bucketsCounter = append(bucketsCounter, metrics.NewRegisteredCounter(fmt.Sprintf("%s/bucket/%d/count", moduleName, i), nil))
|
||||
bucketsCounter[i] = metrics.NewRegisteredCounter(fmt.Sprintf("%s/bucket/%d/count", moduleName, i), nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue