Since make_shared is a constructor, the mesh data was copied over each time we started a new layer. Properly fix this by using smart-pointers from the beginning, so we only have the creation overhead, which is nearly nothing. In fact, this solution may be faster than the original, perhaps due to some constness that is now also enforced.
Fix slowdown issue due to copy of large data.
Since
make_shared
is a constructor, the mesh data was copied over each time we started a new layer. Properly fix this by using smart-pointers from the beginning, so we only have the creation overhead, which is nearly nothing. In fact, this solution may be faster than the original, perhaps due to some constness that is now also enforced.Supersedes #1950