-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace debug_Assert with assert
- Loading branch information
Showing
1 changed file
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,8 +119,8 @@ pub fn save_bmp(path: &str, pixels: &[u8], width: u32, height: u32) -> Result<() | |
/// This function is optimized for performance and uses pointer-based | ||
/// operations to copy the data as fast as possible. | ||
pub fn copy_fast(src: &[u8], dst: &mut [u8], count: usize) { | ||
debug_assert!(src.len() >= count); | ||
debug_assert!(dst.len() >= count); | ||
assert!(src.len() >= count); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
joamag
Author
Owner
|
||
assert!(dst.len() >= count); | ||
|
||
unsafe { | ||
let src_ptr = src.as_ptr(); | ||
|
Hi, sorry to bother but instead of using
assert!
, you can use the safe counterpartcopy_from_slice
https://doc.rust-lang.org/std/primitive.slice.html#method.copy_from_sliceIt does the same thing as your code i. e. bound checking and
ptr::copy_nonoverlapping