Skip to content

Avoid overallocating or growing Vec in Clone#295

Merged
xacrimon merged 1 commit into
xacrimon:masterfrom
GnomedDev:improve-clone-impl
Feb 1, 2025
Merged

Avoid overallocating or growing Vec in Clone#295
xacrimon merged 1 commit into
xacrimon:masterfrom
GnomedDev:improve-clone-impl

Conversation

@GnomedDev

Copy link
Copy Markdown
Contributor

We can collect directly into the Box<[T]> to avoid pushing to a Vec, which could overallocate and require a reallocation when shrinking in Vec::into_boxed_slice or have to reallocate multiple times as it wouldn't know the finishing capacity.

@xacrimon
xacrimon merged commit 39864b2 into xacrimon:master Feb 1, 2025
@GnomedDev
GnomedDev deleted the improve-clone-impl branch February 3, 2025 11:18
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.

2 participants