I have implemented a function that resets the content of the pointer to a structure:
template <typename Struct> void initialize(Struct* s) { *s = Struct{}; } I have performance issues when Struct becomes big (above 10K) because Struct is created in the stack and then assigned to *s. I was wondering if I could improve it:
- Is it possible to initialize directly
*swithout the temporaryStruct{}object? - Should I instead evaluate the size of
Structand build it in the heap if it is big?
Thank you in advance
https://stackoverflow.com/questions/66467465/reset-directly-the-content-of-a-pointer-to-a-struct March 04, 2021 at 09:52AM
没有评论:
发表评论