perf: speed up G-code export by 3-9% via cached config lookups (#16028)

This commit is contained in:
Kris Austin
2026-10-02 19:34:47 -03:00
committed by GitHub
parent 222c6a2df5
commit eb30ea1eb8
7 changed files with 148 additions and 33 deletions
+7 -5
View File
@@ -4298,10 +4298,11 @@ Polygons Print::get_extruder_shared_printable_polygon() const
return shared_printable_polys;
}
// Narrow the stored grouping result to the layer-aware type the slicing pipeline uses.
std::shared_ptr<MultiNozzleUtils::LayeredNozzleGroupResult> Print::get_layered_nozzle_group_result() const
void Print::set_nozzle_group_result(std::shared_ptr<MultiNozzleUtils::NozzleGroupResultBase> result)
{
return std::dynamic_pointer_cast<MultiNozzleUtils::LayeredNozzleGroupResult>(m_nozzle_group_result);
m_nozzle_group_result = std::move(result);
m_layered_nozzle_group_result = std::dynamic_pointer_cast<MultiNozzleUtils::LayeredNozzleGroupResult>(m_nozzle_group_result);
++m_config_index_generation;
}
// Dynamic (per-layer selector) regroup predicate.
@@ -4337,6 +4338,7 @@ int Print::get_filament_config_indx(int filament_id, int layer_id, bool use_cach
void Print::update_filament_self_index_cache()
{
m_missing_nozzle_group_logged.clear(); // reset the per-slice get_config_index log dedupe
++m_config_index_generation;
std::vector<int> values;
if (m_full_print_config.has("filament_self_index")) {
@@ -4376,7 +4378,7 @@ int Print::get_nozzle_config_index(int filament_id, int layer_id)
int Print::get_config_index(int filament_id, int layer_id, const std::vector<std::string> &variant_list, const std::vector<int>& self_index_list, FilamentIndexMap *index_map)
{
auto group_result = get_layered_nozzle_group_result();
const MultiNozzleUtils::LayeredNozzleGroupResult *group_result = m_layered_nozzle_group_result.get();
// Orca: defensive — when no grouping producer has published a result yet, fall back to the
// static identity: one filament-variant column per filament.
if (!group_result)
@@ -4411,7 +4413,7 @@ int Print::get_config_index(int filament_id, int layer_id, const std::vector<std
int Print::get_config_index(int filament_id, int layer_id, const std::vector<std::string> &variant_list, const std::vector<int>& self_index_list, PrintIndexMap &index_map)
{
auto group_result = get_layered_nozzle_group_result();
const MultiNozzleUtils::LayeredNozzleGroupResult *group_result = m_layered_nozzle_group_result.get();
// Orca: same static fallback as the filament overload; the slot degenerates to the filament's
// extruder column (filament_map is 1 based, get_extruder_id guards the filament id range).
if (!group_result)