Skip to main content
4 events
when toggle format what by license comment
Sep 6, 2018 at 22:15 vote accept Snorrlaxxx
Aug 9, 2018 at 8:56 comment added papagaga @Snorrlaxxx: an empty vector shouldn't use memory beyond the bare minimum (data, capacity, size). So initialize data as a null pointer, and don't grow the buffer before elements are pushed back into it. / indeed, capacity = source.size() should be good.
Aug 8, 2018 at 23:01 comment added Snorrlaxxx Thank you for your answer. For the memory management section, for the comment "Why would you initialize all your vectors with room for at least 100 elements?", what do you suggest I do to fix this issue? On the same section, you say "don't add this initial_capacity to the capacity of the vector you're copying (in deepCopy), it's a waste of memory." Do you suggest I take I change it to just capacity = source.size?
Aug 8, 2018 at 9:57 history answered papagaga CC BY-SA 4.0