diff options
| author | Nicolas Koch <nioko1337@gmail.com> | 2018-05-24 14:51:59 +0200 |
|---|---|---|
| committer | Nicolas Koch <nioko1337@gmail.com> | 2018-05-24 14:51:59 +0200 |
| commit | 3f392abdfb2ec0f436352d349eedd5f6707bf817 (patch) | |
| tree | ad68babe6962075b833548d82f9eeab2ad528c14 /src/libstd | |
| parent | 09d03bc245b27728c9cdd4976114506ae20208a7 (diff) | |
| download | rust-3f392abdfb2ec0f436352d349eedd5f6707bf817.tar.gz rust-3f392abdfb2ec0f436352d349eedd5f6707bf817.zip | |
Implement suggestions from the PR
- Move loading of atomic bool outside the loop - Add comment about TryFrom for future improvement
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sys/unix/fs.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 8412540934e..6624c48cbe0 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -818,14 +818,16 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> { (metadata.permissions(), metadata.size()) }; + let has_copy_file_range = HAS_COPY_FILE_RANGE.load(Ordering::Relaxed); let mut written = 0u64; while written < len { + // TODO should ideally use TryFrom let bytes_to_copy = if len - written > usize::max_value() as u64 { usize::max_value() } else { (len - written) as usize }; - let copy_result = if HAS_COPY_FILE_RANGE.load(Ordering::Relaxed) { + let copy_result = if has_copy_file_range { let copy_result = unsafe { // We actually don't have to adjust the offsets, // because copy_file_range adjusts the file offset automatically |
