-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Audit suffix_array #56
Comments
@hucsmn merged those changes; there are still |
Nice! This one is going to be easy to lint, too: when |
Yes, and there is |
|
@Shnatsel Sure, my point was that in the case of non-copy types, the use of Update: moving that discussion to the Clippy issue, your example there was fairly enlightening. |
FYI, the use of It's just... particularly unsafe, as it requires you to ensure that you're properly avoiding any double-drops that might result from it (depending on the particular way it's being used) as well as ensure that you're not actually directly exposing bitwise copies of non-Copy types to safe code at any time. See the |
The upstream code is now 100% safe, Clippy lint is requested. Closing this issue. I've also opened a PR to showcase these improvements in safety-dance trophy case: #62 |
Dependency of
qbsdiff
by the same author.Noticed 2 patterns:
std::ptr::copy_nonoverlapping(&src_slice[i] as *const T, &mut dst_slice[j] as *mut T, n)
All non-UB uses can be replaced with
dst.slice[j..j+n].copy_from_slice(src_slice[i..i+n])
.std::ptr::copy(&s[i] as *const T, &mut s[j] as *mut T, n)
Same idea, non-UB uses can be replaced with
s.copy_within(i..i+n, j)
.If the ranges are non-overlapping, it might be faster to use
slice::split_at_mut
andcopy_from_slice
(resulting in a call tostd::ptr::copy_nonoverlapping
)Should we request a clippy lint?
Fixes sent upstream: hucsmn/suffix_array#1
The text was updated successfully, but these errors were encountered: