Skip to content

Avoid allocating memory for empty shared vectors - #21

Merged
nical merged 1 commit into
mainfrom
default-cap
Aug 3, 2026
Merged

Avoid allocating memory for empty shared vectors#21
nical merged 1 commit into
mainfrom
default-cap

Conversation

@nical

@nical nical commented Aug 3, 2026

Copy link
Copy Markdown
Owner

This is achieved by having them all share a global immutable header with length and capacity set to zero.

This only works with allocators that have nothing to store and nothing to drop, and with items and allocators with an alignment equal or less than 64 bytes. If these requirements are not met, the vector allocates a header of its own.

This is achieved by having them all share a global immutable header with
length and capacity set to zero.

This only works with allocators that have nothing to store and nothing to
drop, and with items and allocators with an alignment equal or less than
64 bytes. If these requirements are not met, the vector allocates a header
of its own.
@nical
nical merged commit 36621c1 into main Aug 3, 2026
3 checks passed
@nical
nical deleted the default-cap branch August 3, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant