<commit_before>//
// Copyright(c) 2015 <NAME>.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//

#pragma once

#include "spdlog/details/log_msg.h"
#include "spdlog/details/os.h"
#include "spdlog/fmt/fmt.h"
#include "spdlog/formatter.h"

#include <array>
#include <chrono>
#include <ctime>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <utility>
#include <vector>

namespace { // Some fmt helpers to efficiently format and pad ints and strings
inline void append_str(const std::string &str, fmt::memory_buffer &dest)
{
    const char *str_ptr = str.data();
    dest.append(str_ptr, str_ptr + str.size());
}

inline void append_buf(const fmt::memory_buffer &buf, fmt::memory_buffer &dest)
{
    const char *buf_ptr = buf.data();
    dest.append(buf_ptr, buf_ptr + buf.size());
}

inline void append_int(int n, fmt::memory_buffer &dest)
{
    fmt::format_int i(n);
    dest.append(i.data(), i.data() + i.size());
}

inline void append_size_t(size_t n, fmt::memory_buffer &dest)
{
    fmt::format_int i(n);
    dest.append(i.data(), i.data() + i.size());
}

inline void append_and_pad2(int n, fmt::memory_buffer &dest)
{
    if (n > 9)
    {
        append_int(n, dest);
        return;
    }
    if (n >= 0) // 0-9
    {
        dest.push_back('0');
        append_int(n, dest);
        return;
    }
    // negatives (unlikely but just in case, let fmt deal with it)
    fmt::format_to(dest, "{:02}", n);
}

inline void append_and_pad3(int n, fmt::memory_buffer &dest)
{
    if (n > 99)
    {
        append_int(n, dest);
        return;
    }
    if (n > 9) // 10-99
    {
        dest.push_back('0');
        append_int(n, dest);
        return;
    }
    if (n >= 0)
    {
        dest.push_back('0');
        dest.push_back('0');
        append_int(n, dest);
        return;
    }
    // negatives (unlikely, but just in case let fmt deal with it)
    fmt::format_to(dest, "{:03}", n);
}

void append_and_pad6(int n, fmt::memory_buffer &dest)
{
    if (n > 99999)
    {
        append_int(n, dest);
        return;
    }
    if (n > 9999)
    {
        dest.push_back('0');
    }

    else if (n > 999)
    {
        dest.push_back('0');
        dest.push_back('0');
    }
    else if (n > 99)
    {
        dest.push_back('0');
        dest.push_back('0');
        dest.push_back('0');
    }
    else if (n > 9)
    {
        dest.push_back('0');
        dest.push_back('0');
        dest.push_back('0');<commit_msg>-mpattern_formatter small change in pad3<commit_after>//
// Copyright(c) 2015 <NAME>.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//

#pragma once

#include "spdlog/details/log_msg.h"
#include "spdlog/details/os.h"
#include "spdlog/fmt/fmt.h"
#include "spdlog/formatter.h"

#include <array>
#include <chrono>
#include <ctime>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <utility>
#include <vector>

namespace { // Some fmt helpers to efficiently format and pad ints and strings
inline void append_str(const std::string &str, fmt::memory_buffer &dest)
{
    const char *str_ptr = str.data();
    dest.append(str_ptr, str_ptr + str.size());
}

inline void append_buf(const fmt::memory_buffer &buf, fmt::memory_buffer &dest)
{
    const char *buf_ptr = buf.data();
    dest.append(buf_ptr, buf_ptr + buf.size());
}

inline void append_int(int n, fmt::memory_buffer &dest)
{
    fmt::format_int i(n);
    dest.append(i.data(), i.data() + i.size());
}

inline void append_size_t(size_t n, fmt::memory_buffer &dest)
{
    fmt::format_int i(n);
    dest.append(i.data(), i.data() + i.size());
}

inline void append_and_pad2(int n, fmt::memory_buffer &dest)
{
    if (n > 9)
    {
        append_int(n, dest);
        return;
    }
    if (n >= 0) // 0-9
    {
        dest.push_back('0');
        append_int(n, dest);
        return;
    }
    // negatives (unlikely but just in case, let fmt deal with it)
    fmt::format_to(dest, "{:02}", n);
}

inline void append_and_pad3(int n, fmt::memory_buffer &dest)
{
    if (n > 99)
    {
        append_int(n, dest);
        return;
    }
    if (n > 9) // 10-99
    {
        dest.push_back('0');
    }
    else if (n >= 0)
    {
        dest.push_back('0');
        dest.push_back('0');
    }
    // negatives (unlikely, but just in case let fmt deal with it)
    else
    {
        fmt::format_to(dest, "{:03}", n);
        return;
    }
    append_int(n, dest);
}

void append_and_pad6(int n, fmt::memory_buffer &dest)
{
    if (n > 99999)
    {
        append_int(n, dest);
        return;
    }
    if (n > 9999)
    {
        dest.push_back('0');
    }

    else if (n > 999)
    {
        dest.push_back('0');
        dest.push_back('0');
    }
    else if (n > 99)
    {
        dest.push_back('0');
        dest.push_back('0');
        dest.push_back('0');
    }
    else if (n > 9)
    {
        dest.push_back('0');
        dest.push_back('0');
        dest.push_back('0');
{'fraction_non_alphanumeric': 0.16378269617706237, 'fraction_numerical': 0.020724346076458754, 'mean_word_length': 2.5130742049469963, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 43, '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': '6030483', 'n_tokens_mistral': 1896, 'n_tokens_neox': 1833, 'n_words': 424}