From 39d2eb30cf259a93ee8d6ba136cd02c44d88274e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20IRMAK?= Date: Sun, 14 Jun 2026 17:23:02 +0300 Subject: [PATCH 1/2] perf: bulk-copy fast path for List(u8, _) deserialize --- src/utils.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils.zig b/src/utils.zig index 126c441..5364701 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -72,6 +72,13 @@ pub fn List(T: type, comptime N: usize) type { const alloc = allocator orelse return error.AllocatorRequired; out.* = try init(alloc); + if (comptime Self.Item == u8) { + // route through deserialize's existing []u8 fast path + if (serialized.len > N) return error.OffsetExceedsSize; + try out.inner.resize(alloc, serialized.len); + return deserialize([]u8, serialized, &out.inner.items, null); + } + // FastSSZ-style capacity optimization: pre-allocate based on input size // TODO: replace this with the definite value, taken from the list if (serialized.len > 0) { From a9d6dbeb6557b5674cab3cebb9d253409fbe435a Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Wed, 15 Jul 2026 22:59:16 +0200 Subject: [PATCH 2/2] skip call to deserialize altogether to remove ambiguity --- src/utils.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils.zig b/src/utils.zig index 5364701..9dd0027 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -73,10 +73,11 @@ pub fn List(T: type, comptime N: usize) type { out.* = try init(alloc); if (comptime Self.Item == u8) { - // route through deserialize's existing []u8 fast path + // bulk-copy fast path: bytes are their own SSZ encoding if (serialized.len > N) return error.OffsetExceedsSize; - try out.inner.resize(alloc, serialized.len); - return deserialize([]u8, serialized, &out.inner.items, null); + try out.inner.ensureTotalCapacityPrecise(alloc, serialized.len); + out.inner.appendSliceAssumeCapacity(serialized); + return; } // FastSSZ-style capacity optimization: pre-allocate based on input size