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.
This commit is contained in:
bubnikv 2017-10-17 16:01:18 +02:00
parent a91d7cb2f7
commit 3731820c48
14 changed files with 1475 additions and 934 deletions

View file

@ -389,7 +389,7 @@ bool Print::apply_config(DynamicPrintConfig config)
// handle changes to print config
t_config_option_keys print_diff = this->config.diff(config);
this->config.apply(config, print_diff, true);
this->config.apply_only(config, print_diff, true);
bool invalidated = this->invalidate_state_by_config_options(print_diff);
// handle changes to object config defaults
@ -410,7 +410,7 @@ bool Print::apply_config(DynamicPrintConfig config)
}
// check whether the new config is different from the current one
t_config_option_keys diff = object->config.diff(new_config);
object->config.apply(new_config, diff, true);
object->config.apply_only(new_config, diff, true);
invalidated |= object->invalidate_state_by_config_options(diff);
}
@ -460,7 +460,7 @@ bool Print::apply_config(DynamicPrintConfig config)
if (this_region_config_set) {
t_config_option_keys diff = region.config.diff(this_region_config);
if (! diff.empty()) {
region.config.apply(this_region_config, diff);
region.config.apply_only(this_region_config, diff);
for (PrintObject *object : this->objects)
if (region_id < object->region_volumes.size() && ! object->region_volumes[region_id].empty())
invalidated |= object->invalidate_state_by_config_options(diff);