<commit_before>package riff

import (
	"io"
)

type Bytes struct {
	Offset uint32
	Reader io.ReaderAt
}

func newBytes(r io.ReaderAt) (bytes *Bytes) {
	bytes = &Bytes{0, r}

	return
}

func (bytes *Bytes) readLEUint32() uint32 {
	offset := bytes.Offset
	data := make([]byte, 4)

	n, err := bytes.Reader.ReadAt(data, int64(offset))

	if err != nil || n < 4 {
		panic("Can't read bytes")
	}

	defer func() {
		bytes.Offset += 4
	}()

	return uint32(data[3])<<24 +
		uint32(data[2])<<16 +
		uint32(data[1])<<8 +
		uint32(data[0])
}

func (bytes *Bytes) readLEUint16() uint16 {
	offset := bytes.Offset
	data := make([]byte, 2)

	n, err := bytes.Reader.ReadAt(data, int64(offset))

	if err != nil || n < 2 {
		panic("Can't read bytes")
	}

	defer func() {
		bytes.Offset += 2
	}()

	return uint16(data[1])<<8 + uint16(data[0])
}

func (bytes *Bytes) readLEInt16() int16 {
	offset := bytes.Offset
	data := make([]byte, 2)

	n, err := bytes.Reader.ReadAt(data, int64(offset))

	if err != nil || n < 2 {
		panic("Can't read bytes")
	}

	defer func() {
		bytes.Offset += 2
	}()

	return int16(data[offset+1])<<8 + int16(data[offset])
}

func (bytes *Bytes) readBytes(size uint32) []byte {
	offset := bytes.Offset
	data := make([]byte, size)

	n, err := bytes.Reader.ReadAt(data, int64(offset))

	if err != nil || n < int(size) {
		panic("Can't read bytes")
	}

	defer func() {
		bytes.Offset += size
	}()

	return data[0:size]
}<commit_msg>refactor<commit_after>package riff

import (
	"io"
)

type Bytes struct {
	Offset uint32
	Reader io.ReaderAt
}

func newBytes(r io.ReaderAt) (bytes *Bytes) {
	bytes = &Bytes{0, r}

	return
}

func (bytes *Bytes) readLEUint32() uint32 {
	offset := bytes.Offset
	data := make([]byte, 4)

	n, err := bytes.Reader.ReadAt(data, int64(offset))

	if err != nil || n < 4 {
		panic("Can't read bytes")
	}

	defer func() {
		bytes.Offset += 4
	}()

	return uint32(data[3])<<24 +
		uint32(data[2])<<16 +
		uint32(data[1])<<8 +
		uint32(data[0])
}

func (bytes *Bytes) readLEUint16() uint16 {
	offset := bytes.Offset
	data := make([]byte, 2)

	n, err := bytes.Reader.ReadAt(data, int64(offset))

	if err != nil || n < 2 {
		panic("Can't read bytes")
	}

	defer func() {
		bytes.Offset += 2
	}()

	return uint16(data[1])<<8 + uint16(data[0])
}

func (bytes *Bytes) readLEInt16() int16 {
	offset := bytes.Offset
	data := make([]byte, 2)

	n, err := bytes.Reader.ReadAt(data, int64(offset))

	if err != nil || n < 2 {
		panic("Can't read bytes")
	}

	defer func() {
		bytes.Offset += 2
	}()

	return int16(data[offset+1])<<8 + int16(data[offset])
}

func (bytes *Bytes) readBytes(size uint32) []byte {
	offset := bytes.Offset
	data := make([]byte, size)

	n, err := bytes.Reader.ReadAt(data, int64(offset))

	if err != nil || n < int(size) {
		panic("Can't read bytes")
	}

	defer func() {
		bytes.Offset += size
	}()

	return data
}
{'fraction_non_alphanumeric': 0.18848718848718848, 'fraction_numerical': 0.04527904527904528, 'mean_word_length': 3.7107438016528924, 'pattern_counts': {'":': 0, '<': 31, '<?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': '1574675', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1113, 'n_words': 276}