• :3 3: :3 3: :3 3: :3
    link
    English
    6
    edit-2
    2 months ago

    Which is why you should:

    1. Preallocate the vector if you can guesstimate the size
    2. Use a vector library that won’t reallocate the entire vector on every single addition (like Rust, whose Vec doubles in size every time it runs out of space)

    Memory is fairly cheap. Allocation time not so much.