mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
chore: reduce allocations
This commit is contained in:
parent
4bdbaab471
commit
6f8e5beefa
5 changed files with 6 additions and 6 deletions
|
|
@ -82,8 +82,8 @@ func showAttributeCounts(ns nodeSet) {
|
|||
}
|
||||
}
|
||||
|
||||
var keys []string
|
||||
var maxlength int
|
||||
keys := make([]string, 0, len(attrcount))
|
||||
for key := range attrcount {
|
||||
keys = append(keys, key)
|
||||
if len(key) > maxlength {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ func blockTestCmd(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
// Run them in order
|
||||
var keys []string
|
||||
keys := make([]string, 0, len(tests))
|
||||
for key := range tests {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ func readInput(ctx *cli.Context) (*bbInput, error) {
|
|||
}
|
||||
// Deserialize rlp txs and ommers
|
||||
var (
|
||||
ommers = []*types.Header{}
|
||||
ommers = make([]*types.Header, 0, len(inputData.OmmersRlp))
|
||||
txs = []*types.Transaction{}
|
||||
)
|
||||
if inputData.TxRlp != "" {
|
||||
|
|
|
|||
|
|
@ -832,7 +832,7 @@ func decreaseKey(key []byte) []byte {
|
|||
|
||||
func BenchmarkProve(b *testing.B) {
|
||||
trie, vals := randomTrie(100)
|
||||
var keys []string
|
||||
keys := make([]string, 0, len(vals))
|
||||
for k := range vals {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
|
@ -850,8 +850,8 @@ func BenchmarkProve(b *testing.B) {
|
|||
func BenchmarkVerifyProof(b *testing.B) {
|
||||
trie, vals := randomTrie(100)
|
||||
root := trie.Hash()
|
||||
var keys []string
|
||||
var proofs []*memorydb.Database
|
||||
keys := make([]string, 0, len(vals))
|
||||
for k := range vals {
|
||||
keys = append(keys, k)
|
||||
proof := memorydb.New()
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ func testAccessList(t *testing.T, vals []struct{ k, v string }) {
|
|||
parent = root
|
||||
trie, _ = New(TrieID(root), db)
|
||||
orig = trie.Copy()
|
||||
var keys []string
|
||||
keys := make([]string, 0, 30)
|
||||
for i := 0; i < 30; i++ {
|
||||
key := randBytes(32)
|
||||
keys = append(keys, string(key))
|
||||
|
|
|
|||
Loading…
Reference in a new issue