The capacity doesn't always double. When it's grown to ~1024 (depends on OS) there applies another logic to increase the capacity of a slice.
Thanks for the feedback! Will update the post with that info
This behavior changed in go 1.18 to more smooth allocation: starting cap growth factor 256 2.0 512 1.63 1024 1.44 2048 1.35 4096 1.30
commit: github.com/golang/go/commit/2dda92...
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The capacity doesn't always double. When it's grown to ~1024 (depends on OS) there applies another logic to increase the capacity of a slice.
Thanks for the feedback! Will update the post with that info
This behavior changed in go 1.18 to more smooth allocation:
starting cap growth factor
256 2.0
512 1.63
1024 1.44
2048 1.35
4096 1.30
commit:
github.com/golang/go/commit/2dda92...