3 ms·
Small is fine but empty would be a bad default in my view.
by Ididntdothis 7y ago
Small is fine but empty would be a bad default in my view.
- asveikau 7y agoBut isn't resizing from 0 to n pretty much the same as allocating a fresh one of size n? (Not talking about the typical "resizing for n inserts one-at-a-time" approach, just going from zero to something.) I mean, you have conditionals in the insert instead of unconditional allocation at the start, so maybe a little worse for things like branch predictors, but ...
- Ididntdothis 7y agoYou have a point there. In sum you would probably get the same performance. The only difference would be that the first insert would be slower vs the constructor as it is now.