FIX: performance issue caused by copy LayerResult

jira:NONE

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I5f1bda598ef096999a0eda2fa68d2a24c97c22ca
This commit is contained in:
xun.zhang 2024-09-29 16:13:51 +08:00 committed by lane.wei
parent 8360bd2473
commit d9ea1a4b24
2 changed files with 29 additions and 1 deletions

View File

@ -2528,7 +2528,10 @@ void GCode::process_layers(
//BBS
check_placeholder_parser_failed();
print.throw_if_canceled();
return this->process_layer(print, layer.second, layer_tools, &layer == &layers_to_print.back(), &print_object_instances_ordering, size_t(-1));
GCode::LayerResult res = this->process_layer(print, layer.second, layer_tools, &layer == &layers_to_print.back(), &print_object_instances_ordering, size_t(-1));
res.gcode_store_pos = layer_to_print_idx - 1;
layers_results[layer_to_print_idx - 1] = std::move(res);
return layers_results[layer_to_print_idx - 1];
}
});
if (m_spiral_vase) {

View File

@ -296,6 +296,31 @@ private:
bool spiral_vase_enable { false };
// Should the cooling buffer content be flushed at the end of this layer?
bool cooling_buffer_flush { false };
// the layer store pos of gcode
size_t gcode_store_pos;
LayerResult() = default;
LayerResult(const std::string& gcode_, const size_t layer_id_, const bool spiral_vase_enable_, const bool cooling_buffer_flush_, const size_t gcode_store_pos_ = static_cast<size_t>(-1)) :
gcode(gcode_), layer_id(layer_id_), spiral_vase_enable(spiral_vase_enable_), cooling_buffer_flush(cooling_buffer_flush_), gcode_store_pos(gcode_store_pos_){}
LayerResult(const LayerResult& other) = default;
LayerResult& operator=(const LayerResult& other) = default;
LayerResult(LayerResult&& other) noexcept {
gcode = std::move(other.gcode);
layer_id = other.layer_id;
spiral_vase_enable = other.spiral_vase_enable;
cooling_buffer_flush = other.cooling_buffer_flush;
gcode_store_pos = other.gcode_store_pos;
}
LayerResult& operator=(LayerResult&& other) noexcept {
if (this != &other) {
gcode = std::move(other.gcode);
layer_id = other.layer_id;
spiral_vase_enable = other.spiral_vase_enable;
cooling_buffer_flush = other.cooling_buffer_flush;
gcode_store_pos = other.gcode_store_pos;
}
return *this;
}
};
LayerResult process_layer(
const Print &print,