I was just looking at TList.Grow (and TStringList.Grow) and I realized that the numbers are a bit odd - is that intentional for some reason?

I was just looking at TList.Grow (and TStringList.Grow) and I realized that the numbers are a bit odd - is that intentional for some reason?

When adding 1024 items it grows like this:
4, 8, 12, 28, 44, 60, 76, 95, 118, 147, 183, 228, 285, 356, 445, 556, 695, 868, 1085

When using TList the growing is exponential (as it is the case in the .NET List):
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024

I know that if you know the count of the items you want to add it is better to preset the capacity - my question however is what implementation of grow would be better as a default? Or are there even better ways like growing in fixed steps based on the current capacity?

Comments