c-vector icon indicating copy to clipboard operation
c-vector copied to clipboard

Feature suggestion: Shrink arrays

Open julianhartmer opened this issue 3 years ago • 1 comments

What do you think about automatic shrinking of c-vectors? Currently, the vector capacity doubles when capacity == size. How about cutting the vector capacity in half when the (size >> 2) < capacity? This way, the capacity is cut in half when only a fourth of the capacity is used. I could make this feature optional by enabling it when CVECTOR_SHRINK is defined. What are your thoughts?

julianhartmer avatar Jul 11 '22 22:07 julianhartmer

I'm open to it, especially if controlled by a macro so it's opt in. I'd also be even more in favor of a cvector_shrink_to_fit macro of some kind that would resize the vector to be an exact fit when the user wants it so.

eteran avatar Jul 13 '22 19:07 eteran