diff --git a/core/rawdb/chain_freezer.go b/core/rawdb/chain_freezer.go index 7a0b819b6fa0..4904d6ba9123 100644 --- a/core/rawdb/chain_freezer.go +++ b/core/rawdb/chain_freezer.go @@ -132,10 +132,7 @@ func (f *chainFreezer) freezeThreshold(db ethdb.KeyValueReader) (uint64, error) if final == 0 && headLimit == 0 { return 0, errors.New("freezing threshold is not available") } - if final > headLimit { - return final, nil - } - return headLimit, nil + return max(final, headLimit), nil } // freeze is a background thread that periodically checks the blockchain for any diff --git a/core/txpool/blobpool/priority.go b/core/txpool/blobpool/priority.go index 7ae7f92def12..457e4c20bf88 100644 --- a/core/txpool/blobpool/priority.go +++ b/core/txpool/blobpool/priority.go @@ -36,10 +36,7 @@ func evictionPriority(basefeeJumps float64, txBasefeeJumps, blobfeeJumps, txBlob basefeePriority = evictionPriority1D(basefeeJumps, txBasefeeJumps) blobfeePriority = evictionPriority1D(blobfeeJumps, txBlobfeeJumps) ) - if basefeePriority < blobfeePriority { - return basefeePriority - } - return blobfeePriority + return min(basefeePriority, blobfeePriority) } // evictionPriority1D calculates the eviction priority based on the algorithm diff --git a/core/vm/contracts.go b/core/vm/contracts.go index f54d5ab86e66..6a705ba63336 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -426,10 +426,7 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 { return math.MaxUint64 } // 3. Minimum price of 200 gas - if gas.Uint64() < 200 { - return 200 - } - return gas.Uint64() + return max(200, gas.Uint64()) } gas = modexpMultComplexity(gas) if adjExpLen.Cmp(big1) > 0 { diff --git a/core/vm/memory_table.go b/core/vm/memory_table.go index 28746042cf3b..df13d4c8aebf 100644 --- a/core/vm/memory_table.go +++ b/core/vm/memory_table.go @@ -73,10 +73,7 @@ func memoryCall(stack *Stack) (uint64, bool) { if overflow { return 0, true } - if x > y { - return x, false - } - return y, false + return max(x, y), false } func memoryDelegateCall(stack *Stack) (uint64, bool) { @@ -88,10 +85,7 @@ func memoryDelegateCall(stack *Stack) (uint64, bool) { if overflow { return 0, true } - if x > y { - return x, false - } - return y, false + return max(x, y), false } func memoryStaticCall(stack *Stack) (uint64, bool) { @@ -103,10 +97,7 @@ func memoryStaticCall(stack *Stack) (uint64, bool) { if overflow { return 0, true } - if x > y { - return x, false - } - return y, false + return max(x, y), false } func memoryReturn(stack *Stack) (uint64, bool) { diff --git a/ethdb/leveldb/leveldb.go b/ethdb/leveldb/leveldb.go index f18503c94154..01bcfdde4968 100644 --- a/ethdb/leveldb/leveldb.go +++ b/ethdb/leveldb/leveldb.go @@ -358,9 +358,7 @@ func (db *Database) meter(refresh time.Duration, namespace string) { continue } // Iterate over all the leveldbTable rows, and accumulate the entries - for j := 0; j < len(compactions[i%2]); j++ { - compactions[i%2][j] = 0 - } + clear(compactions[i%2]) compactions[i%2][0] = stats.LevelSizes.Sum() for _, t := range stats.LevelDurations { compactions[i%2][1] += t.Nanoseconds()