Skip to content

Commit 3f392ab

Browse files
committed
Implement suggestions from the PR
- Move loading of atomic bool outside the loop - Add comment about TryFrom for future improvement
1 parent 09d03bc commit 3f392ab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/libstd/sys/unix/fs.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,14 +818,16 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
818818
(metadata.permissions(), metadata.size())
819819
};
820820

821+
let has_copy_file_range = HAS_COPY_FILE_RANGE.load(Ordering::Relaxed);
821822
let mut written = 0u64;
822823
while written < len {
824+
// TODO should ideally use TryFrom
823825
let bytes_to_copy = if len - written > usize::max_value() as u64 {
824826
usize::max_value()
825827
} else {
826828
(len - written) as usize
827829
};
828-
let copy_result = if HAS_COPY_FILE_RANGE.load(Ordering::Relaxed) {
830+
let copy_result = if has_copy_file_range {
829831
let copy_result = unsafe {
830832
// We actually don't have to adjust the offsets,
831833
// because copy_file_range adjusts the file offset automatically

0 commit comments

Comments
 (0)