<commit_before>package xz

import (
	"errors"
	"io"
)

// padWriter supports the writing of padding aligned to a block size.
// padWriter remembers errors.
type padWriter struct {
	w         io.Writer
	n         int64
	blockSize int
	pad       []byte
	err       error
}

// newPadWriter creates a new pad writer.
func newPadWriter(w io.Writer, blockSize int) *padWriter {
	if blockSize < 1 {
		blockSize = 1
	}
	return &padWriter{
		w:         w,
		blockSize: blockSize,
		pad:       make([]byte, blockSize-1),
	}
}

// Write writes the slide to the underlying writer.
func (w *padWriter) Write(p []byte) (n int, err error) {
	if w.err != nil {
		return 0, w.err
	}
	n, err = w.w.Write(p)
	w.n += int64(n)
	w.err = err
	return n, err
}

// Pad writes the pad to align the stream with the block size.
func (w *padWriter) Pad() (n int, err error) {
	if w.err != nil {
		return 0, w.err
	}
	k := int(w.n % int64(w.blockSize))
	if k == 0 {
		return 0, nil
	}
	n, err = w.Write(w.pad[:w.blockSize-k])
	w.err = err
	return n, err
}

// PadReader supports the reading of pads from a reader.
type padReader struct {
	r         io.Reader
	n         int64
	blockSize int
	p         []byte
	err       error
}

// newPadReader creates a new pad reader.
func newPadReader(r io.Reader, blockSize int) *padReader {
	if blockSize < 1 {
		blockSize = 1
	}
	return &padReader{
		r:         r,
		blockSize: blockSize,
		p:         make([]byte, blockSize-1),
	}
}

// Read reads data from the underlying reader.
func (r *padReader) Read(p []byte) (n int, err error) {
	if r.err != nil {
		return 0, r.err
	}
	n, err = r.r.Read(p)
	r.n += int64(n)
	r.err = err
	return n, err
}

// Pad reads the padding from the underlying reader.
func (r *padReader) Pad() (n int, err error) {
	if r.err != nil {
		return 0, r.err
	}
	k := int(r.n % int64(r.blockSize))
	if k == 0 {
		return 0, nil
	}
	if n, err = io.ReadFull(r, r.p[:r.blockSize-k]); err != nil {
		r.err = err
		return n, err
	}
	for _, c := range r.p[:n] {
		if c != 0 {
			r.err = errors.New("xz: non-zero padding byte")
			return n, r.err
		}
	}
	return n, nil
}
<commit_msg>xz: removed error field of padReader and padWriter<commit_after>package xz

import (
	"errors"
	"io"
)

// padWriter supports the writing of padding aligned to a block size.
// padWriter remembers errors.
type padWriter struct {
	w         io.Writer
	n         int64
	blockSize int
	pad       []byte
}

// newPadWriter creates a new pad writer.
func newPadWriter(w io.Writer, blockSize int) *padWriter {
	if blockSize < 1 {
		blockSize = 1
	}
	return &padWriter{
		w:         w,
		blockSize: blockSize,
		pad:       make([]byte, blockSize-1),
	}
}

// Write writes the slide to the underlying writer.
func (w *padWriter) Write(p []byte) (n int, err error) {
	n, err = w.w.Write(p)
	w.n += int64(n)
	return n, err
}

// Pad writes the pad to align the stream with the block size.
func (w *padWriter) Pad() (n int, err error) {
	k := int(w.n % int64(w.blockSize))
	if k == 0 {
		return 0, nil
	}
	n, err = w.Write(w.pad[:w.blockSize-k])
	return n, err
}

// PadReader supports the reading of pads from a reader.
type padReader struct {
	r         io.Reader
	n         int64
	blockSize int
	p         []byte
}

// newPadReader creates a new pad reader.
func newPadReader(r io.Reader, blockSize int) *padReader {
	if blockSize < 1 {
		blockSize = 1
	}
	return &padReader{
		r:         r,
		blockSize: blockSize,
		p:         make([]byte, blockSize-1),
	}
}

// Read reads data from the underlying reader.
func (r *padReader) Read(p []byte) (n int, err error) {
	n, err = r.r.Read(p)
	r.n += int64(n)
	return n, err
}

// Pad reads the padding from the underlying reader.
func (r *padReader) Pad() (n int, err error) {
	k := int(r.n % int64(r.blockSize))
	if k == 0 {
		return 0, nil
	}
	if n, err = io.ReadFull(r, r.p[:r.blockSize-k]); err != nil {
		return n, err
	}
	for _, c := range r.p[:n] {
		if c != 0 {
			return n, errors.New("xz: non-zero padding byte")
		}
	}
	return n, nil
}

{'fraction_non_alphanumeric': 0.13316645807259073, 'fraction_numerical': 0.012515644555694618, 'mean_word_length': 2.552, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1239153', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1519, 'n_words': 519}