Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How do the results change if you use DynArray.make and pass the count instead of DynArray.create? I think the comment you're replying to was talking about preallocated static arrays, not dynamically resizing ones.


It's still marginally slower at 760 milliseconds, give or take (I suspect that's because major heap allocations are generally more expensive than nursery allocations). That said, in that case I could also use `List.init` and be even faster.

The problem is that often you don't know exactly how much memory you'll preallocate. This is where in (say) C++, you'll resort to an arena or pool allocator; a GC with a bump allocator will give you what is essentially a smart arena allocator by default for your temporary allocations.




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

Search: