4 ms·
I don't believe C++ compilers can do optimizations around allocation. A quick test at https://godbolt.org/g/lFQcKf https://godbolt.org/g/lFQcKf reveals that gcc
by dooglius 10y ago
I don't believe C++ compilers can do optimizations around allocation. A quick test at https://godbolt.org/g/lFQcKf https://godbolt.org/g/lFQcKf reveals that gcc does not appear to coalesce STL operations, or move the allocation to the stack. The compiler is much dumber than most people think it is.
- pcwalton 10y agoLLVM can remove allocations that are unused, but that's it. There's been talk of doing escape analysis for allocations on the mailing list, but so far nothing has been done as far as I know.
- vbezhenar 10y agoI'm not sure I follow you, but std::list implementation stores object data inside node, so it's only a single allocation per node, as it should be.