<commit_before>#pragma once

#include <cctype>
#include "types.hpp"

static inline u32 bytes2word(u8 *bytes)
{
	return
		(bytes[0] << 24) |
		(bytes[1] << 16) |
		(bytes[2] <<  8) |
		(bytes[3] <<  0);
}

static inline void word2bytes(u32 word, u8 *bytes)
{
	bytes[0] = word >> 24;
	bytes[1] = (word >> 16) & 0xff;
	bytes[2] = (word >>  8) & 0xff;
	bytes[3] = word & 0xff;
}

static inline void bytes_add(u8 *bytes, u32 word)
{
	word2bytes(bytes2word(bytes) + word, bytes);
}

static inline void cstring_to_upper_case(char *str)
{
	for (int i = 0; str[i]; i++)
		str[i] = toupper(str[i]);
}

#define streq(a, b) strcmp(a, b) == 0<commit_msg>utils.hpp: hardened streq(), simplified cstring_to_upper_case()<commit_after>#pragma once

#include <cctype>
#include <cstring>

#include "types.hpp"

static inline u32 bytes2word(u8 *bytes)
{
	return
		(bytes[0] << 24) |
		(bytes[1] << 16) |
		(bytes[2] <<  8) |
		(bytes[3] <<  0);
}

static inline void word2bytes(u32 word, u8 *bytes)
{
	bytes[0] = word >> 24;
	bytes[1] = (word >> 16) & 0xff;
	bytes[2] = (word >>  8) & 0xff;
	bytes[3] = word & 0xff;
}

static inline void bytes_add(u8 *bytes, u32 word)
{
	word2bytes(bytes2word(bytes) + word, bytes);
}

static inline void cstring_to_upper_case(char *str)
{
	while ((*str = toupper(*str)))
		++str;
}

static inline bool streq(const char *a, const char *b)
{
	return strcmp(a, b) == 0;
}
{'fraction_non_alphanumeric': 0.1843817787418655, 'fraction_numerical': 0.05278380332610268, 'mean_word_length': 4.242424242424242, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 18, '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': '3251807', 'n_tokens_mistral': 640, 'n_tokens_neox': 592, 'n_words': 148}