More work on dnd kitten

This commit is contained in:
Kovid Goyal
2026-05-02 12:16:42 +05:30
parent 4eb7789f1e
commit ff7c6425e6
5 changed files with 151 additions and 53 deletions

View File

@@ -192,16 +192,16 @@ func (s *StreamingBase64Encoder) Encode(input []byte, output []byte) iter.Seq2[[
// Finish encoding the stream. Resets the encoder. Returned slice can be nil
// if no leftover bytes are present.
func (s *StreamingBase64Encoder) Finish() ([]byte, error) {
func (s *StreamingBase64Encoder) Finish() []byte {
defer func() {
s.num_leftover = 0
s.total_read = 0
}()
if s.num_leftover == 0 {
return nil, nil
return nil
}
encodedLen := base64.RawStdEncoding.EncodedLen(s.num_leftover)
output := make([]byte, encodedLen)
base64.RawStdEncoding.Encode(output, s.leftover[:s.num_leftover])
return output, nil
output := [4]byte{}
base64.RawStdEncoding.Encode(output[:encodedLen], s.leftover[:s.num_leftover])
return output[:encodedLen]
}