<commit_before>#include "Preset.hpp"
#include "Config.hpp"
#include <regex>
#include <algorithm>

#include "Dialogs/PresetEditor.hpp"

using namespace std::literals::string_literals;
using namespace boost;

namespace Slic3r { namespace GUI {

Preset::Preset(std::string load_dir, std::string filename, preset_t p) : group(p), _file(wxFileName(load_dir, filename)) {
    this->name = this->_file.GetName();

    this->_dirty_config = std::make_shared<Slic3r::Config>();
    this->_config = std::make_shared<Slic3r::Config>();
}

t_config_option_keys Preset::dirty_options() const {
    t_config_option_keys dirty;

    auto diff_config = this->_config->diff(this->_dirty_config);
    std::move(diff_config.begin(), diff_config.end(), std::back_inserter(dirty));

    auto extra = this->_group_overrides();
    std::copy_if(extra.cbegin(), extra.cend(), std::back_inserter(dirty), 
            [this](const std::string x) { return !this->_config->has(x) && this->_dirty_config->has(x);});

    dirty.erase(std::remove_if(dirty.begin(), dirty.end(), 
            [this](const std::string x) { return this->_config->has(x) && !this->_dirty_config->has(x);}),
            dirty.end());

    return dirty;
}
<commit_msg>Defaults preset makes a new config from defaults.<commit_after>#include "Preset.hpp"
#include "Config.hpp"
#include <regex>
#include <algorithm>

#include "Dialogs/PresetEditor.hpp"

using namespace std::literals::string_literals;
using namespace boost;

namespace Slic3r { namespace GUI {

Preset::Preset(std::string load_dir, std::string filename, preset_t p) : group(p), _file(wxFileName(load_dir, filename)) {
    this->name = this->_file.GetName();
    t_config_option_keys keylist;
    switch (this->group) {
        case preset_t::Print:
            keylist = PrintEditor::options();
            break;
        case preset_t::Material:
            keylist = MaterialEditor::options();
            break;
        case preset_t::Printer:
            keylist = PrinterEditor::options();
            break;
        default: break;
    }
    this->_dirty_config = Slic3r::Config::new_from_defaults(keylist);
    this->_config = Slic3r::Config::new_from_defaults(keylist);
}

t_config_option_keys Preset::dirty_options() const {
    t_config_option_keys dirty;

    auto diff_config = this->_config->diff(this->_dirty_config);
    std::move(diff_config.begin(), diff_config.end(), std::back_inserter(dirty));

    auto extra = this->_group_overrides();
    std::copy_if(extra.cbegin(), extra.cend(), std::back_inserter(dirty), 
            [this](const std::string x) { return !this->_config->has(x) && this->_dirty_config->has(x);});

    dirty.erase(std::remove_if(dirty.begin(), dirty.end(), 
            [this](const std::string x) { return this->_config->has(x) && !this->_dirty_config->has(x);}),
            dirty.end());

    return dirty;
}

{'fraction_non_alphanumeric': 0.15986038394415358, 'fraction_numerical': 0.0020942408376963353, 'mean_word_length': 4.163963963963964, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 42, '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': '4581848', 'n_tokens_mistral': 929, 'n_tokens_neox': 922, 'n_words': 166}