Ultimaker / CuraEngine

Powerful, fast and robust engine for converting 3D models into g-code instructions for 3D printers. It is part of the larger open source project Cura.
https://ultimaker.com/en/products/cura-software
GNU Affero General Public License v3.0
1.66k stars 876 forks source link

[CURA-11019] speed-fix (ugly? raw pointer edition) #1950

Closed rburema closed 10 months ago

rburema commented 10 months ago

The make_shared function copies the entire object, since it's in essence a sort of emplace for a smart-pointer version of the constructor of an object. Which means basically that the copy-constructor is called in the case where an object is inserted into make_shared. This is normally not so bad, but this is an object representing an entire layer, with non-pointer member-variables. It didn't happen that often, but each operation was quite expensive.

The solution presented here is maybe a bit ugly, but we should either accept raw pointers (because the original object is on the stack and manages itself -- a lot less risk of dangling pointers or whatever), or we go all the way and start constructing it as a smart-pointer in the first place.

(I also made some pass-by-copy into pass-by-reference changes, since smart pointers are still objects, so probably slightly bigger than a reference.)

github-actions[bot] commented 10 months ago

Unit Test Results

26 tests   26 :heavy_check_mark:  13s :stopwatch:   1 suites    0 :zzz:   1 files      0 :x:

Results for commit f6d31c92.

rburema commented 10 months ago

Closed in favour of #1951