From 694635d52f3b7f5c94fe06cf65ed688c5a62aad0 Mon Sep 17 00:00:00 2001 From: Matt Dainty Date: Fri, 18 Nov 2022 00:36:46 +0000 Subject: [PATCH] Refactor PaddedReader with FillReader --- padded.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/padded.go b/padded.go index cb7f027..675c85d 100644 --- a/padded.go +++ b/padded.go @@ -1,7 +1,6 @@ package plumbing import ( - "bytes" "io" ) @@ -9,6 +8,5 @@ import ( // fewer than n bytes are available from r then any remaining bytes return // fill instead. func PaddedReader(r io.Reader, n int64, fill byte) io.Reader { - // Naive, but works - return io.LimitReader(io.MultiReader(r, bytes.NewBuffer(bytes.Repeat([]byte{fill}, int(n)))), n) + return io.LimitReader(io.MultiReader(r, FillReader(fill)), n) }