Hacker News new | past | comments | ask | show | jobs | submit login

I meant something close to https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p04...

Perhaps a simple way to look at it is that it's like a dynamic array, but when the capacity is exceeded, you don't reallocate the array, just just allocate a new (exponentially larger) chunk and keep the old one as-is. Then just link the chunks in a (very short) linked list, or keep a separate small list of chunks (you're never gonna need more than 48, so you can just have a fixed allocation for it), or what have you. The bonus here is that it reduces latency on pushing and has more predictable performance.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: