From 9ee65abaaa626faddc2a29ad5ee073901360b991 Mon Sep 17 00:00:00 2001 From: Sahil-4555 Date: Tue, 16 Dec 2025 11:09:17 +0530 Subject: [PATCH] core/rawdb: refactor headerHashKey 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 a1e07a78a2..c9ef0d3df3 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -204,7 +204,15 @@ func headerKey(number uint64, hash common.Hash) []byte { // headerHashKey = headerPrefix + num (uint64 big endian) + headerHashSuffix func headerHashKey(number uint64) []byte { - return append(append(headerPrefix, encodeBlockNumber(number)...), headerHashSuffix...) + totalLen := len(headerPrefix) + 8 + len(headerHashSuffix) + out := make([]byte, totalLen) + + off := 0 + off += copy(out[off:], headerPrefix) + off += copy(out[off:], encodeBlockNumber(number)) + copy(out[off:], headerHashSuffix) + + return out } // headerNumberKey = headerNumberPrefix + hash