hashbrown icon indicating copy to clipboard operation
hashbrown copied to clipboard

Remove unnecessary `add` in `clone_from_impl`

Open JustForFun88 opened this issue 1 year ago • 1 comments

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

JustForFun88 avatar Apr 11 '24 15:04 JustForFun88

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.

Amanieu avatar Apr 16 '24 10:04 Amanieu