Skip to content

Commit 2cd25fd

Browse files
authored
internal/ethapi: remove double map-clone (#30788)
`ActivePrecompiledContracts()` clones the precompiled contract map, thus its callsite does not need to clone it
1 parent a25be32 commit 2cd25fd

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

internal/ethapi/api.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"encoding/hex"
2222
"errors"
2323
"fmt"
24-
"maps"
2524
gomath "math"
2625
"math/big"
2726
"strings"
@@ -254,7 +253,7 @@ func (api *TxPoolAPI) Inspect() map[string]map[string]map[string]string {
254253
pending, queue := api.b.TxPoolContent()
255254

256255
// Define a formatter to flatten a transaction into a string
257-
var format = func(tx *types.Transaction) string {
256+
format := func(tx *types.Transaction) string {
258257
if to := tx.To(); to != nil {
259258
return fmt.Sprintf("%s: %v wei + %v gas × %v wei", tx.To().Hex(), tx.Value(), tx.Gas(), tx.GasPrice())
260259
}
@@ -825,7 +824,7 @@ func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.S
825824
blockOverrides.Apply(&blockCtx)
826825
}
827826
rules := b.ChainConfig().Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time)
828-
precompiles := maps.Clone(vm.ActivePrecompiledContracts(rules))
827+
precompiles := vm.ActivePrecompiledContracts(rules)
829828
if err := overrides.Apply(state, precompiles); err != nil {
830829
return nil, err
831830
}
@@ -1762,11 +1761,11 @@ func (api *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs,
17621761
matchTx := sendArgs.ToTransaction(types.LegacyTxType)
17631762

17641763
// Before replacing the old transaction, ensure the _new_ transaction fee is reasonable.
1765-
var price = matchTx.GasPrice()
1764+
price := matchTx.GasPrice()
17661765
if gasPrice != nil {
17671766
price = gasPrice.ToInt()
17681767
}
1769-
var gas = matchTx.Gas()
1768+
gas := matchTx.Gas()
17701769
if gasLimit != nil {
17711770
gas = uint64(*gasLimit)
17721771
}

0 commit comments

Comments
 (0)