4 ms·
> Unlikely, because the allocator would need to know things only the compilers knows Such as ?
by soulbadguy 3y ago
> Unlikely, because the allocator would need to know things only the compilers knows
Such as ?
- flohofwoe 3y agoSuch a 'smart allocator' can't just work with a size and alignment, it also needs to know the internal structure of objects so that it can arrange them differently (maybe to remove padding bytes, maybe to turn arrays-of-structs into structs-of-arrays. And in turn the compiler needs to know how the 'allocator' has rearranged things in order to generate the code which accesses the data. I also wasn't thinking about moving parts of a struct out into heap allocations, I think in most situations that would be worse than having to deal with padding. Instead at least have the programmer think about how the internal memory layout of sum types might affect performance in specific situations instead of just using them everywhere and in mass because they are convenient.