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.)
The
make_shared
function copies the entire object, since it's in essence a sort ofemplace
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 intomake_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.)