<commit_before>/*
 * Format stuff into string.
 *
 * author: <NAME> <<EMAIL>>
 */

#ifndef __BENG_FORMAT_H
#define __BENG_FORMAT_H

#include "compiler.h"

#include <stdint.h>
#include <string.h>

extern const char hex_digits[0x10];


static attr_always_inline void
format_2digit(char *dest, unsigned number)
{
    dest[0] = '0' + number / 10;
    dest[1] = '0' + number % 10;
}

static attr_always_inline void
format_4digit(char *dest, unsigned number)
{
    dest[0] = '0' + number / 1000;
    dest[1] = '0' + (number / 100) % 10;
    dest[2] = '0' + (number / 10) % 10;
    dest[3] = '0' + number % 10;
}

static attr_always_inline void
format_uint16_hex_fixed(char dest[4], uint16_t number) {
    dest[0] = hex_digits[(number >> 12) & 0xf];
    dest[1] = hex_digits[(number >> 8) & 0xf];
    dest[2] = hex_digits[(number >> 4) & 0xf];
    dest[3] = hex_digits[number & 0xf];
}

/**
 * Format a 64 bit unsigned integer into a decimal string.
 */
static attr_always_inline void
format_uint64(char dest[32], uint64_t number)
{
    char *p = dest + sizeof(dest) - 1;

    *p = 0;
    do {
        --p;
        *p = '0' + (number % 10);
        number /= 10;
    } while (number != 0);

    if (p > dest)
        memmove(dest, p, dest + sizeof(dest) - p);
}

/**
 * Format a 32 bit unsigned integer into a hex string.
 */
static attr_always_inline void
format_uint32_hex(char dest[9], uint32_t number)
{
    char *p = dest + sizeof(dest) - 1;

    *p = 0;
    do {
        --p;
        *p = hex_digits[number % 0x10];
        number /= 0x10;
    } while (number != 0);

    if (p > dest)
        memmove(dest, p, dest + sizeof(dest) - p);
}

#endif<commit_msg>back to hard coded instead of sizeof()<commit_after>/*
 * Format stuff into string.
 *
 * author: <NAME> <<EMAIL>>
 */

#ifndef __BENG_FORMAT_H
#define __BENG_FORMAT_H

#include "compiler.h"

#include <stdint.h>
#include <string.h>

extern const char hex_digits[0x10];


static attr_always_inline void
format_2digit(char *dest, unsigned number)
{
    dest[0] = '0' + number / 10;
    dest[1] = '0' + number % 10;
}

static attr_always_inline void
format_4digit(char *dest, unsigned number)
{
    dest[0] = '0' + number / 1000;
    dest[1] = '0' + (number / 100) % 10;
    dest[2] = '0' + (number / 10) % 10;
    dest[3] = '0' + number % 10;
}

static attr_always_inline void
format_uint16_hex_fixed(char dest[4], uint16_t number) {
    dest[0] = hex_digits[(number >> 12) & 0xf];
    dest[1] = hex_digits[(number >> 8) & 0xf];
    dest[2] = hex_digits[(number >> 4) & 0xf];
    dest[3] = hex_digits[number & 0xf];
}

/**
 * Format a 64 bit unsigned integer into a decimal string.
 */
static attr_always_inline void
format_uint64(char dest[32], uint64_t number)
{
    char *p = dest + 32 - 1;

    *p = 0;
    do {
        --p;
        *p = '0' + (number % 10);
        number /= 10;
    } while (number != 0);

    if (p > dest)
        memmove(dest, p, dest + 32 - p);
}

/**
 * Format a 32 bit unsigned integer into a hex string.
 */
static attr_always_inline void
format_uint32_hex(char dest[9], uint32_t number)
{
    char *p = dest + 9 - 1;

    *p = 0;
    do {
        --p;
        *p = hex_digits[number % 0x10];
        number /= 0x10;
    } while (number != 0);

    if (p > dest)
        memmove(dest, p, dest + 9 - p);
}

#endif
{'fraction_non_alphanumeric': 0.15711252653927812, 'fraction_numerical': 0.05338186229905975, 'mean_word_length': 2.7181510710259302, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, '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': '3771645', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1257, 'n_words': 345}