<commit_before>#include <zpuino.h>
#include <zpuino-types.h>

template<unsigned int iobase>
class HardwareSerial
{
private:
public:
	HardwareSerial(){}

	void begin(const unsigned int &baudrate);

	/* Constant-value begin - much faster */
	template<const unsigned int baudrate>
		void beginStatic() {
			REGISTER(IO_SLOT(iobase),1) = BAUDRATEGEN(baudrate);
		}

	int available(void) const;
	int peek(void) {};
	int read(void) const;
	void flush(void) {};
	void write(unsigned char c);
	void write(const char *c);
};


extern HardwareSerial<1> Serial; /* 1st slot */


template<unsigned int base>
	void HardwareSerial<base>::begin(const unsigned int &baudrate) {
		REGISTER(IO_SLOT(base),1) = BAUDRATEGEN(baudrate);
	}

template<unsigned int base>
	int HardwareSerial<base>::available() const {
		return (REGISTER(IO_SLOT(base),1) & 1);
	}

template<unsigned int base>
	int HardwareSerial<base>::read() const {
		return REGISTER(IO_SLOT(base),0);
	}

template<unsigned int base>
	void HardwareSerial<base>::write(unsigned char c) {
		while ((REGISTER(IO_SLOT(base),1) & 2)==2);
		REGISTER(IO_SLOT(base),0) = c;
	}

template<unsigned int base>
	void HardwareSerial<base>::write(const char *c) {
		while (*c) {
			write(*c);
			c++;
		}
	}
<commit_msg>serial: do proper inlining for baudrate computation<commit_after>#include <zpuino.h>
#include <zpuino-types.h>

template<unsigned int iobase>
	class HardwareSerial
{
private:
public:
	HardwareSerial(){}

	__attribute__((always_inline)) static inline void begin(const unsigned int baudrate) {
		if (__builtin_constant_p(baudrate)) {
			REGISTER(IO_SLOT(iobase),1) = BAUDRATEGEN(baudrate);
		} else {
			begin_slow(baudrate);
		}
	}
	static void begin_slow(const unsigned int baudrate);

	int available(void) const;
	int peek(void) {};
	int read(void) const;
	void flush(void) {};
	void write(unsigned char c);
	void write(const char *c);
};


extern HardwareSerial<1> Serial; /* 1st slot */

template<unsigned int base>
void HardwareSerial<base>::begin_slow(const unsigned int baudrate) {
	REGISTER(IO_SLOT(base),1) = BAUDRATEGEN(baudrate);
}

template<unsigned int base>
int HardwareSerial<base>::available() const {
	return (REGISTER(IO_SLOT(base),1) & 1);
}

template<unsigned int base>
int HardwareSerial<base>::read() const {
	return REGISTER(IO_SLOT(base),0);
}

template<unsigned int base>
void HardwareSerial<base>::write(unsigned char c) {
	while ((REGISTER(IO_SLOT(base),1) & 2)==2);
	REGISTER(IO_SLOT(base),0) = c;
}

template<unsigned int base>
void HardwareSerial<base>::write(const char *c) {
	while (*c) {
		write(*c);
		c++;
	}
}

{'fraction_non_alphanumeric': 0.14572089437162683, 'fraction_numerical': 0.008481110254433308, 'mean_word_length': 5.688144329896907, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, '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': '3391509', 'n_tokens_mistral': 988, 'n_tokens_neox': 942, 'n_words': 213}