Performance improvement of GCodeProcessor:

Replaced std::string with std::string_view for constant parameters
Replaced boost:istarts_with() with boost::starts_with()
This commit is contained in:
Vojtech Bubnik 2022-08-18 10:30:20 +02:00 committed by enricoturri1966
parent 3395b288c4
commit a93620621d
2 changed files with 8 additions and 3 deletions

View File

@ -3779,8 +3779,13 @@ void GCodeProcessor::post_process()
}
auto process_used_filament = [&](std::string& gcode_line) {
auto process_tag = [](std::string& gcode_line, const std::string& tag, const std::vector<double>& values) {
if (boost::algorithm::istarts_with(gcode_line, tag)) {
// Prefilter for parsing speed.
if (gcode_line.size() < 8 || gcode_line[0] != ';' || gcode_line[1] != ' ')
return false;
if (const char c = gcode_line[2]; c != 'f' && c != 't')
return false;
auto process_tag = [](std::string& gcode_line, const std::string_view tag, const std::vector<double>& values) {
if (boost::algorithm::starts_with(gcode_line, tag)) {
gcode_line = tag;
char buf[1024];
for (size_t i = 0; i < values.size(); ++i) {

View File

@ -542,7 +542,7 @@ bool ImGuiWrapper::slider_float(const char* label, float* v, float v_min, float
const float max_tooltip_width = ImGui::GetFontSize() * 20.0f;
// let the label string start with "##" to hide the automatic label from ImGui::SliderFloat()
bool label_visible = !boost::algorithm::istarts_with(label, "##");
bool label_visible = !boost::algorithm::starts_with(label, "##");
std::string str_label = label_visible ? std::string("##") + std::string(label) : std::string(label);
// removes 2nd evenience of "##", if present