From f3c1b118dfbfbd81f5737e885f47ea783b15ce0b Mon Sep 17 00:00:00 2001 From: Ivan FB Date: Wed, 10 Jun 2026 17:18:41 +0200 Subject: [PATCH] refactor(protobuf): skip fixed-width fields via skipValue (no alloc) Addresses review feedback: skipping a field by reading its value discards an allocated result. Use the codec's `skipValue`, which advances the stream without materialising the value. (The previous allocating length-delimited discard was already removed by the parse-once change; this applies the same intent to the fixed32/64 skips that remain.) Co-Authored-By: Claude Opus 4.8 --- sds/protobufutil.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sds/protobufutil.nim b/sds/protobufutil.nim index 6566a3e..af87c02 100644 --- a/sds/protobufutil.nim +++ b/sds/protobufutil.nim @@ -23,7 +23,7 @@ import results import faststreams/inputs from protobuf_serialization/codec import FieldHeader, WireKind, init, number, kind, toBytes, readHeader, readValue, - puint64, pbytes, fixed64, fixed32 + skipValue, puint64, pbytes, fixed64, fixed32 import ./types/protobuf_error export results, protobuf_error @@ -69,9 +69,9 @@ proc init*(T: type ProtoBuffer, data: seq[byte]): T = of WireKind.LengthDelim: pb.lengthDelims.mgetOrPut(hdr.number, @[]).add(seq[byte](readValue(stream, pbytes))) of WireKind.Fixed64: - discard readValue(stream, fixed64) + skipValue(stream, fixed64) of WireKind.Fixed32: - discard readValue(stream, fixed32) + skipValue(stream, fixed32) except CatchableError: pb.parseOk = false return pb