From 036ceb8cbbbcf1b1e7cfc85760f0a3b4de551e47 Mon Sep 17 00:00:00 2001 From: chirag-parmar Date: Sat, 14 Dec 2024 14:52:20 +0530 Subject: [PATCH] remove delete operations --- eth/rlp/two_pass_writer.nim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eth/rlp/two_pass_writer.nim b/eth/rlp/two_pass_writer.nim index 454d31e9..8b17e7eb 100644 --- a/eth/rlp/two_pass_writer.nim +++ b/eth/rlp/two_pass_writer.nim @@ -12,6 +12,7 @@ type prefixLengths*: seq[int] listLengths*: seq[int] fillLevel: int + listCount: int func writeCount(writer: var RlpTwoPassWriter, count: int, baseMarker: byte) = if count < THRESHOLD_LIST_LEN: @@ -59,10 +60,9 @@ proc startList*(self: var RlpTwoPassWriter, listSize: int) = if listSize == 0: self.writeCount(0, LIST_START_MARKER) else: - let prefixLen = self.prefixLengths[0] - let listLen = self.listLengths[0] - self.prefixLengths.delete(0) - self.listLengths.delete(0) + let prefixLen = self.prefixLengths[self.listCount] + let listLen = self.listLengths[self.listCount] + self.listCount += 1 if listLen < THRESHOLD_LIST_LEN: self.output[self.fillLevel] = LIST_START_MARKER + byte(listLen) @@ -75,6 +75,7 @@ proc startList*(self: var RlpTwoPassWriter, listSize: int) = func initTwoPassWriter*(length: int): RlpTwoPassWriter = result.fillLevel = 0 + result.listCount = 0 result.output = newSeqOfCap[byte](length) result.output.setLen(length)