<commit_before>#pragma once

#include <algorithm>

namespace penciloid
{
template <typename T>
class AutoArray
{
public:
	AutoArray() : data_(nullptr), length_(0) {}
	AutoArray(int length) :
		data_(new T[length]),
		length_(length) {}
	AutoArray(const AutoArray<T> &other) :
		data_(new T[other.length_]),
		length_(other.length_) {
		std::copy(other.begin(), other.end(), begin());
	}
	AutoArray(AutoArray<T> &&other) :
		data_(other.data_),
		length_(other.length_) {
		other.data_ = nullptr;
		other.length_ = 0;
	}
	~AutoArray() { delete[] data_; }

	AutoArray<T> &operator=(const AutoArray<T> &other) {
		delete[] data_;
		data_ = new T[other.length_];
		length_ = other.length_;
		std::copy(other.begin(), other.end(), begin());

		return *this;
	}
	AutoArray<T> &operator=(AutoArray<T> &&other) {
		delete[] data_;
		data_ = other.data_;
		length_ = other.length_;
		other.data_ = nullptr;
		other.length_ = 0;

		return *this;
	}

	T &operator[](int i) { return data_[i]; }
	const T &operator[](int i) const { return data_[i]; }

	T *begin() { return data_; }
	T *end() { return &(data_[length_]); }
	const T *begin() const { return data_; }
	const T *end() const { return &(data_[length_]); }

private:
	T *data_;
	unsigned int length_;
};
}
<commit_msg>AutoArray: add an optimization in operator=<commit_after>#pragma once

#include <algorithm>

namespace penciloid
{
template <typename T>
class AutoArray
{
public:
	AutoArray() : data_(nullptr), length_(0) {}
	AutoArray(int length) :
		data_(new T[length]),
		length_(length) {}
	AutoArray(const AutoArray<T> &other) :
		data_(new T[other.length_]),
		length_(other.length_) {
		std::copy(other.begin(), other.end(), begin());
	}
	AutoArray(AutoArray<T> &&other) :
		data_(other.data_),
		length_(other.length_) {
		other.data_ = nullptr;
		other.length_ = 0;
	}
	~AutoArray() { delete[] data_; }

	AutoArray<T> &operator=(const AutoArray<T> &other) {
		if (length_ != other.length_) {
			delete[] data_;
			data_ = new T[other.length_];
			length_ = other.length_;
		}
		std::copy(other.begin(), other.end(), begin());

		return *this;
	}
	AutoArray<T> &operator=(AutoArray<T> &&other) {
		delete[] data_;
		data_ = other.data_;
		length_ = other.length_;
		other.data_ = nullptr;
		other.length_ = 0;

		return *this;
	}

	T &operator[](int i) { return data_[i]; }
	const T &operator[](int i) const { return data_[i]; }

	T *begin() { return data_; }
	T *end() { return &(data_[length_]); }
	const T *begin() const { return data_; }
	const T *end() const { return &(data_[length_]); }

private:
	T *data_;
	unsigned int length_;
};
}

{'fraction_non_alphanumeric': 0.16893632683106366, 'fraction_numerical': 0.002208317997791682, 'mean_word_length': 3.514950166112957, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5796381', 'n_tokens_mistral': 1047, 'n_tokens_neox': 956, 'n_words': 226}