Skip to content

Remove unnecessary add in clone_from_impl#519

Closed
JustForFun88 wants to merge 1 commit intorust-lang:masterfrom
JustForFun88:clone_from_impl
Closed

Remove unnecessary add in clone_from_impl#519
JustForFun88 wants to merge 1 commit intorust-lang:masterfrom
JustForFun88:clone_from_impl

Conversation

@JustForFun88
Copy link
Copy Markdown
Contributor

The guard.0 = index + 1 in the implementation of clone_from _impl is completely unnecessary, since an invalid index can be set in advance.

@Amanieu
Copy link
Copy Markdown
Member

Amanieu commented Apr 16, 2024

The + 1 is implicitly calculated by the iterator anyways, so it doesn't cost anything extra in optimized builds.

I prefer the original form of the code since guard.0 clearly indicates the point that separates the initialized part of the array vs the uninitialized part. This also avoids the need to special-case usize::MAX.

@clarfonthey
Copy link
Copy Markdown
Contributor

Going to close for the combined reasoning from Amanieu + the merge conflicts.

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.

3 participants