mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
Small Loop Memory Optimizations (#11887)
# 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.
This commit is contained in:
@@ -315,7 +315,7 @@ static bool is_printable_filament_changed(const DynamicPrintConfig& new_full_con
|
||||
}
|
||||
|
||||
Polygons split_polys;
|
||||
for (const Polygon poly : extruder_polys) {
|
||||
for (const Polygon& poly : extruder_polys) {
|
||||
Polygons res = diff(printable_poly, poly);
|
||||
if (!res.empty()) { split_polys.emplace_back(res[0]); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user