Small Loop Memory Optimizations #1136

Closed
opened 2026-04-05 16:53:16 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @neo-jayfeather on 1/9/2026

Description

src/libslic3r/PrintApply.cpp changes (line 318)

Change const auto to const auto& for loops (simple optimization) .

src/slic3r/Utils/CalibUtils.cpp changes (lines 762, 766, 779, 783/784, 814, 816, 831, 835, 837, 1001)

Define config_pattern
const auto& config_pattern = SuggestedConfigCalibPAPattern(); (line 762 and 814)

Replace calls of SuggestedConfigCalibPAPattern() with config_pattern (lines 766, 775, 779, 783, 784, 816, 831, 835, 837)

Change const auto to const auto& for loops (simple optimization) (lines 816, 835, 837, 1001)

Also gets rid of the five compiler warnings out of the few hundred/thousand (when building the entire project) that warn about copying loop variables
i.e.

/home/neo/git/OrcaSlicer-EDIT-TEMP/src/slic3r/Utils/CalibUtils.cpp:832: warning: loop variable ‘opt’ creates a copy from type ‘const std::pair<std::__cxx11::basic_string<char>, int>’ [-Wrange-loop-construct]
  832 |     for (const auto opt : SuggestedConfigCalibPAPattern().int_pairs) { print_config.set_key_value(opt.first, new ConfigOptionInt(opt.second)); }

Tests

Should have no functional difference. Contains optimizations, calibrations appear to still function well.

*Originally created by @neo-jayfeather on 1/9/2026* # Description ### `src/libslic3r/PrintApply.cpp` changes (line 318) Change `const auto` to `const auto&` for loops (simple optimization) . ### `src/slic3r/Utils/CalibUtils.cpp` changes (lines 762, 766, 779, 783/784, 814, 816, 831, 835, 837, 1001) Define config_pattern `const auto& config_pattern = SuggestedConfigCalibPAPattern();` (line 762 and 814) Replace calls of `SuggestedConfigCalibPAPattern()` with `config_pattern` (lines 766, 775, 779, 783, 784, 816, 831, 835, 837) Change `const auto` to `const auto&` for loops (simple optimization) (lines 816, 835, 837, 1001) *Also gets rid of the five compiler warnings out of the few hundred/thousand (when building the entire project) that warn about copying loop variables* i.e. ```/home/neo/git/OrcaSlicer-EDIT-TEMP/src/slic3r/Utils/CalibUtils.cpp:828: note: use reference type to prevent copying /home/neo/git/OrcaSlicer-EDIT-TEMP/src/slic3r/Utils/CalibUtils.cpp:832: warning: loop variable ‘opt’ creates a copy from type ‘const std::pair<std::__cxx11::basic_string<char>, int>’ [-Wrange-loop-construct] 832 | for (const auto opt : SuggestedConfigCalibPAPattern().int_pairs) { print_config.set_key_value(opt.first, new ConfigOptionInt(opt.second)); } ``` ## Tests Should have no functional difference. Contains optimizations, calibrations appear to still function well.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/OrcaSlicer#1136