From 8d4d653572d4f58c0eedb0e5ccb2e97c1db6b60a Mon Sep 17 00:00:00 2001 From: Sahil-4555 Date: Tue, 16 Dec 2025 11:10:42 +0530 Subject: [PATCH] core/rawdb: refactor blockBodyKey to prealloc + copy --- core/rawdb/schema.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index c9ef0d3df3..a43b01e9d0 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -222,7 +222,15 @@ func headerNumberKey(hash common.Hash) []byte { // blockBodyKey = blockBodyPrefix + num (uint64 big endian) + hash func blockBodyKey(number uint64, hash common.Hash) []byte { - return append(append(blockBodyPrefix, encodeBlockNumber(number)...), hash.Bytes()...) + totalLen := len(blockBodyPrefix) + 8 + common.HashLength + out := make([]byte, totalLen) + + off := 0 + off += copy(out[off:], blockBodyPrefix) + off += copy(out[off:], encodeBlockNumber(number)) + copy(out[off:], hash.Bytes()) + + return out } // blockReceiptsKey = blockReceiptsPrefix + num (uint64 big endian) + hash