mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
prealloc capacity for map and slice
This commit is contained in:
parent
d4b81f0e08
commit
3071d377fb
3 changed files with 4 additions and 4 deletions
|
|
@ -234,7 +234,7 @@ func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
|
|||
for _, abiArg := range abiArgs {
|
||||
inputOffset += getTypeSize(abiArg.Type)
|
||||
}
|
||||
var ret []byte
|
||||
var ret = make([]byte, 0, len(args))
|
||||
for i, a := range args {
|
||||
input := abiArgs[i]
|
||||
// pack the input
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ func ExecutableDataToBlock(params ExecutableData, versionedHashes []common.Hash,
|
|||
if params.BaseFeePerGas != nil && (params.BaseFeePerGas.Sign() == -1 || params.BaseFeePerGas.BitLen() > 256) {
|
||||
return nil, fmt.Errorf("invalid baseFeePerGas: %v", params.BaseFeePerGas)
|
||||
}
|
||||
var blobHashes []common.Hash
|
||||
var blobHashes = make([]common.Hash, 0, len(txs))
|
||||
for _, tx := range txs {
|
||||
blobHashes = append(blobHashes, tx.BlobHashes()...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ func ParseCombinedJSON(combinedJSON []byte, source string, languageVersion strin
|
|||
return parseCombinedJSONV8(combinedJSON, source, languageVersion, compilerVersion, compilerOptions)
|
||||
}
|
||||
// Compilation succeeded, assemble and return the contracts.
|
||||
contracts := make(map[string]*Contract)
|
||||
contracts := make(map[string]*Contract, len(output.Contracts))
|
||||
for name, info := range output.Contracts {
|
||||
// Parse the individual compilation results.
|
||||
var abi, userdoc, devdoc interface{}
|
||||
|
|
@ -107,7 +107,7 @@ func parseCombinedJSONV8(combinedJSON []byte, source string, languageVersion str
|
|||
return nil, err
|
||||
}
|
||||
// Compilation succeeded, assemble and return the contracts.
|
||||
contracts := make(map[string]*Contract)
|
||||
contracts := make(map[string]*Contract, len(output.Contracts))
|
||||
for name, info := range output.Contracts {
|
||||
contracts[name] = &Contract{
|
||||
Code: "0x" + info.Bin,
|
||||
|
|
|
|||
Loading…
Reference in a new issue