mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-21 04:13:50 +00:00
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:
@@ -37,7 +37,7 @@
|
||||
void erase(t_config_option_key opt_key);
|
||||
void normalize();
|
||||
%name{setenv} void setenv_();
|
||||
double min_object_distance();
|
||||
double min_object_distance() %code{% RETVAL = PrintConfig::min_object_distance(THIS); %};
|
||||
%name{_load} void load(std::string file);
|
||||
%name{_load_from_gcode} void load_from_gcode(std::string input_file)
|
||||
%code%{
|
||||
@@ -47,20 +47,20 @@
|
||||
croak("Error extracting configuration from a g-code %s:\n%s\n", input_file.c_str(), e.what());
|
||||
}
|
||||
%};
|
||||
%name{_save} void save(std::string file);
|
||||
void save(std::string file);
|
||||
};
|
||||
|
||||
%name{Slic3r::Config::Static} class StaticPrintConfig {
|
||||
static StaticPrintConfig* new_GCodeConfig()
|
||||
%code{% RETVAL = new GCodeConfig (); %};
|
||||
%code{% RETVAL = new GCodeConfig(); %};
|
||||
static StaticPrintConfig* new_PrintConfig()
|
||||
%code{% RETVAL = new PrintConfig (); %};
|
||||
%code{% RETVAL = new PrintConfig(); %};
|
||||
static StaticPrintConfig* new_PrintObjectConfig()
|
||||
%code{% RETVAL = new PrintObjectConfig (); %};
|
||||
%code{% RETVAL = new PrintObjectConfig(); %};
|
||||
static StaticPrintConfig* new_PrintRegionConfig()
|
||||
%code{% RETVAL = new PrintRegionConfig (); %};
|
||||
%code{% RETVAL = new PrintRegionConfig(); %};
|
||||
static StaticPrintConfig* new_FullPrintConfig()
|
||||
%code{% RETVAL = new FullPrintConfig (); %};
|
||||
%code{% RETVAL = static_cast<PrintObjectConfig*>(new FullPrintConfig()); %};
|
||||
~StaticPrintConfig();
|
||||
bool has(t_config_option_key opt_key);
|
||||
SV* as_hash()
|
||||
@@ -93,10 +93,10 @@
|
||||
}
|
||||
%};
|
||||
%name{setenv} void setenv_();
|
||||
double min_object_distance();
|
||||
double min_object_distance() %code{% RETVAL = PrintConfig::min_object_distance(THIS); %};
|
||||
%name{_load} void load(std::string file);
|
||||
%name{_load_from_gcode} void load_from_gcode(std::string file);
|
||||
%name{_save} void save(std::string file);
|
||||
void save(std::string file);
|
||||
};
|
||||
|
||||
%package{Slic3r::Config};
|
||||
|
||||
Reference in New Issue
Block a user