Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-10-17 17:01:18 +0300
committerbubnikv <bubnikv@gmail.com>2017-10-17 17:01:18 +0300
commit3731820c480668236156abaa0ea568d89a08d8dd (patch)
tree982db37b7ab704c3242c0fb25101fb56ba39b8a3 /xs/src/perlglue.cpp
parenta91d7cb2f73e62a84ca3f2c2d174cd0854e74f4d (diff)
Optimization of the configuration layer:
The values of StaticPrintConfig derived objects were searched by a name walking through a huge chained if. Now they are being mapped with a std::map. Also initialization of StaticPrintConfig classes from their ConfigOptionDef defaults is done by maintaining a single global definition of each StaticPrintConfig derived class, and a new instance is initialized from this static copy. Also the ConfigOption instances are casted using static_cast wherever possible, and their types are verified by a virtual type() method. This approach avoids insiginificant performance penalty of a dynamic_cast. Also the compare and clone methods were added to ConfigOption, and the cloning & compare work on binary values, not by serialization.
Diffstat (limited to 'xs/src/perlglue.cpp')
-rw-r--r--xs/src/perlglue.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/xs/src/perlglue.cpp b/xs/src/perlglue.cpp
index 3b7a62299..e7f03d1f5 100644
--- a/xs/src/perlglue.cpp
+++ b/xs/src/perlglue.cpp
@@ -77,7 +77,7 @@ ConfigBase__get(ConfigBase* THIS, const t_config_option_key &opt_key) {
ConfigOption* opt = THIS->option(opt_key);
if (opt == NULL) return &PL_sv_undef;
- const ConfigOptionDef* def = THIS->def->get(opt_key);
+ const ConfigOptionDef* def = THIS->def()->get(opt_key);
return ConfigOption_to_SV(*opt, *def);
}
@@ -155,7 +155,7 @@ ConfigBase__get_at(ConfigBase* THIS, const t_config_option_key &opt_key, size_t
ConfigOption* opt = THIS->option(opt_key);
if (opt == NULL) return &PL_sv_undef;
- const ConfigOptionDef* def = THIS->def->get(opt_key);
+ const ConfigOptionDef* def = THIS->def()->get(opt_key);
if (def->type == coFloats || def->type == coPercents) {
ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt);
return newSVnv(optv->get_at(i));
@@ -183,7 +183,7 @@ ConfigBase__set(ConfigBase* THIS, const t_config_option_key &opt_key, SV* value)
ConfigOption* opt = THIS->option(opt_key, true);
if (opt == NULL) CONFESS("Trying to set non-existing option");
- const ConfigOptionDef* def = THIS->def->get(opt_key);
+ const ConfigOptionDef* def = THIS->def()->get(opt_key);
if (def->type == coFloat) {
if (!looks_like_number(value)) return false;
ConfigOptionFloat* optv = dynamic_cast<ConfigOptionFloat*>(opt);
@@ -297,7 +297,7 @@ ConfigBase__set_ifndef(ConfigBase* THIS, const t_config_option_key &opt_key, SV*
bool
StaticConfig__set(StaticConfig* THIS, const t_config_option_key &opt_key, SV* value) {
- const ConfigOptionDef* optdef = THIS->def->get(opt_key);
+ const ConfigOptionDef* optdef = THIS->def()->get(opt_key);
if (!optdef->shortcut.empty()) {
for (std::vector<t_config_option_key>::const_iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it) {
if (!StaticConfig__set(THIS, *it, value)) return false;