all: prefer new(big.Int) over big.NewInt(0) (#25087)

minor performance improvement: `big.NewInt(0).Xxx` -> `new(big.Int).Xxx`
This commit is contained in:
lmittmann
2022-06-14 15:09:48 +03:00
committed by GitHub
parent 8cfd1214b7
commit bc013bc42e
12 changed files with 22 additions and 24 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ func (c *Chain) Len() int {
// TD calculates the total difficulty of the chain at the
// chain head.
func (c *Chain) TD() *big.Int {
sum := big.NewInt(0)
sum := new(big.Int)
for _, block := range c.blocks[:c.Len()] {
sum.Add(sum, block.Difficulty())
}
@@ -57,7 +57,7 @@ func (c *Chain) TD() *big.Int {
// TotalDifficultyAt calculates the total difficulty of the chain
// at the given block height.
func (c *Chain) TotalDifficultyAt(height int) *big.Int {
sum := big.NewInt(0)
sum := new(big.Int)
if height >= c.Len() {
return sum
}