From e73ce53d8fdb251fbee26d76094550d3c0d5d5a3 Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Tue, 30 Jun 2026 14:54:39 +0200 Subject: bench: improve accuracy in byte accounting and reuse the scanner --- scanner.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'scanner.go') diff --git a/scanner.go b/scanner.go index 4169f1f..0978ab4 100644 --- a/scanner.go +++ b/scanner.go @@ -52,6 +52,12 @@ func NewScanner(rs io.ReadSeeker) Scanner { return Scanner{rs: rs} } +// Reset discards all state and prepares the Scanner to read from rs. It lets a +// single Scanner be reused for multiple streams without reallocating. +func (s *Scanner) Reset(rs io.ReadSeeker) { + *s = Scanner{rs: rs} +} + // Next advances to the next top-level box. Returns false when there // are no more boxes or an error occurs. Check Err() after the loop. func (s *Scanner) Next() bool { -- cgit v1.3.1