diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp index 741151c38..e388d8f9b 100644 --- a/xs/src/libslic3r/Config.cpp +++ b/xs/src/libslic3r/Config.cpp @@ -8,7 +8,7 @@ namespace Slic3r { bool -ConfigBase::has(const t_config_option_key opt_key) { +ConfigBase::has(const t_config_option_key &opt_key) { return (this->option(opt_key, false) != NULL); } @@ -52,14 +52,14 @@ ConfigBase::diff(ConfigBase &other) { } std::string -ConfigBase::serialize(const t_config_option_key opt_key) { +ConfigBase::serialize(const t_config_option_key &opt_key) { ConfigOption* opt = this->option(opt_key); assert(opt != NULL); return opt->serialize(); } bool -ConfigBase::set_deserialize(const t_config_option_key opt_key, std::string str) { +ConfigBase::set_deserialize(const t_config_option_key &opt_key, std::string str) { if (this->def->count(opt_key) == 0) throw "Calling set_deserialize() on unknown option"; ConfigOptionDef* optdef = &(*this->def)[opt_key]; if (!optdef->shortcut.empty()) { @@ -75,7 +75,7 @@ ConfigBase::set_deserialize(const t_config_option_key opt_key, std::string str) } double -ConfigBase::get_abs_value(const t_config_option_key opt_key) { +ConfigBase::get_abs_value(const t_config_option_key &opt_key) { ConfigOption* opt = this->option(opt_key, false); if (ConfigOptionFloatOrPercent* optv = dynamic_cast(opt)) { // get option definition @@ -92,7 +92,7 @@ ConfigBase::get_abs_value(const t_config_option_key opt_key) { } double -ConfigBase::get_abs_value(const t_config_option_key opt_key, double ratio_over) { +ConfigBase::get_abs_value(const t_config_option_key &opt_key, double ratio_over) { // get stored option value ConfigOptionFloatOrPercent* opt = dynamic_cast(this->option(opt_key)); assert(opt != NULL); @@ -282,7 +282,7 @@ ConfigBase::set(t_config_option_key opt_key, SV* value) { /* This method is implemented as a workaround for this typemap bug: https://rt.cpan.org/Public/Bug/Display.html?id=94110 */ bool -ConfigBase::set_deserialize(const t_config_option_key opt_key, SV* str) { +ConfigBase::set_deserialize(const t_config_option_key &opt_key, SV* str) { size_t len; const char * c = SvPV(str, len); std::string value(c, len); @@ -328,7 +328,7 @@ DynamicConfig::DynamicConfig (const DynamicConfig& other) { } ConfigOption* -DynamicConfig::option(const t_config_option_key opt_key, bool create) { +DynamicConfig::option(const t_config_option_key &opt_key, bool create) { if (this->options.count(opt_key) == 0) { if (create) { ConfigOptionDef* optdef = &(*this->def)[opt_key]; @@ -375,16 +375,16 @@ DynamicConfig::option(const t_config_option_key opt_key, bool create) { template T* -DynamicConfig::opt(const t_config_option_key opt_key, bool create) { +DynamicConfig::opt(const t_config_option_key &opt_key, bool create) { return dynamic_cast(this->option(opt_key, create)); } -template ConfigOptionInt* DynamicConfig::opt(const t_config_option_key opt_key, bool create); -template ConfigOptionBool* DynamicConfig::opt(const t_config_option_key opt_key, bool create); -template ConfigOptionBools* DynamicConfig::opt(const t_config_option_key opt_key, bool create); -template ConfigOptionPercent* DynamicConfig::opt(const t_config_option_key opt_key, bool create); +template ConfigOptionInt* DynamicConfig::opt(const t_config_option_key &opt_key, bool create); +template ConfigOptionBool* DynamicConfig::opt(const t_config_option_key &opt_key, bool create); +template ConfigOptionBools* DynamicConfig::opt(const t_config_option_key &opt_key, bool create); +template ConfigOptionPercent* DynamicConfig::opt(const t_config_option_key &opt_key, bool create); const ConfigOption* -DynamicConfig::option(const t_config_option_key opt_key) const { +DynamicConfig::option(const t_config_option_key &opt_key) const { return const_cast(this)->option(opt_key, false); } @@ -397,7 +397,7 @@ DynamicConfig::keys() const { } void -DynamicConfig::erase(const t_config_option_key opt_key) { +DynamicConfig::erase(const t_config_option_key &opt_key) { this->options.erase(opt_key); } @@ -412,7 +412,7 @@ StaticConfig::keys() const { } const ConfigOption* -StaticConfig::option(const t_config_option_key opt_key) const +StaticConfig::option(const t_config_option_key &opt_key) const { return const_cast(this)->option(opt_key, false); } diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index be433633d..2d192d235 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -512,18 +512,18 @@ class ConfigBase t_optiondef_map* def; ConfigBase() : def(NULL) {}; - bool has(const t_config_option_key opt_key); - virtual ConfigOption* option(const t_config_option_key opt_key, bool create = false) = 0; - virtual const ConfigOption* option(const t_config_option_key opt_key) const = 0; + bool has(const t_config_option_key &opt_key); + virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0; + virtual const ConfigOption* option(const t_config_option_key &opt_key) const = 0; virtual t_config_option_keys keys() const = 0; void apply(const ConfigBase &other, bool ignore_nonexistent = false); bool equals(ConfigBase &other); t_config_option_keys diff(ConfigBase &other); - std::string serialize(const t_config_option_key opt_key); - bool set_deserialize(const t_config_option_key opt_key, std::string str); + std::string serialize(const t_config_option_key &opt_key); + bool set_deserialize(const t_config_option_key &opt_key, std::string str); void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false); - double get_abs_value(const t_config_option_key opt_key); - double get_abs_value(const t_config_option_key opt_key, double ratio_over); + double get_abs_value(const t_config_option_key &opt_key); + double get_abs_value(const t_config_option_key &opt_key, double ratio_over); void setenv_(); #ifdef SLIC3RXS @@ -531,7 +531,7 @@ class ConfigBase SV* get(t_config_option_key opt_key); SV* get_at(t_config_option_key opt_key, size_t i); bool set(t_config_option_key opt_key, SV* value); - bool set_deserialize(const t_config_option_key opt_key, SV* str); + bool set_deserialize(const t_config_option_key &opt_key, SV* str); #endif }; @@ -543,11 +543,11 @@ class DynamicConfig : public ConfigBase DynamicConfig& operator= (DynamicConfig other); void swap(DynamicConfig &other); ~DynamicConfig(); - template T* opt(const t_config_option_key opt_key, bool create = false); - ConfigOption* option(const t_config_option_key opt_key, bool create = false); - const ConfigOption* option(const t_config_option_key opt_key) const; + template T* opt(const t_config_option_key &opt_key, bool create = false); + ConfigOption* option(const t_config_option_key &opt_key, bool create = false); + const ConfigOption* option(const t_config_option_key &opt_key) const; t_config_option_keys keys() const; - void erase(const t_config_option_key opt_key); + void erase(const t_config_option_key &opt_key); private: typedef std::map t_options_map; @@ -558,8 +558,8 @@ class StaticConfig : public ConfigBase { public: t_config_option_keys keys() const; - virtual ConfigOption* option(const t_config_option_key opt_key, bool create = false) = 0; - const ConfigOption* option(const t_config_option_key opt_key) const; + virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0; + const ConfigOption* option(const t_config_option_key &opt_key) const; #ifdef SLIC3RXS bool set(t_config_option_key opt_key, SV* value); diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 012135e01..5e8d542c9 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -150,7 +150,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig this->xy_size_compensation.value = 0; }; - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(dont_support_bridges); OPT_PTR(extrusion_width); OPT_PTR(first_layer_height); @@ -260,7 +260,7 @@ class PrintRegionConfig : public virtual StaticPrintConfig this->top_solid_layers.value = 3; }; - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(bottom_solid_layers); OPT_PTR(bridge_flow_ratio); OPT_PTR(bridge_speed); @@ -359,7 +359,7 @@ class GCodeConfig : public virtual StaticPrintConfig this->use_volumetric_e.value = false; }; - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(before_layer_gcode); OPT_PTR(end_gcode); OPT_PTR(extrusion_axis); @@ -518,7 +518,7 @@ class PrintConfig : public GCodeConfig this->z_offset.value = 0; }; - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(avoid_crossing_perimeters); OPT_PTR(bed_shape); OPT_PTR(bed_temperature); @@ -589,7 +589,7 @@ class HostConfig : public virtual StaticPrintConfig this->octoprint_apikey.value = ""; }; - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { OPT_PTR(octoprint_host); OPT_PTR(octoprint_apikey); @@ -601,7 +601,7 @@ class FullPrintConfig : public PrintObjectConfig, public PrintRegionConfig, public PrintConfig, public HostConfig { public: - ConfigOption* option(const t_config_option_key opt_key, bool create = false) { + ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { ConfigOption* opt; if ((opt = PrintObjectConfig::option(opt_key, create)) != NULL) return opt; if ((opt = PrintRegionConfig::option(opt_key, create)) != NULL) return opt;