• :3 3: :3 3: :3 3: :3
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    8 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.