Skip to content

Commit

Permalink
try out the unstable copy_within interface
Browse files Browse the repository at this point in the history
We won't be able to land this in master for probably several major Rust
versions, but it's nice to see it working. Tracking issue:
rust-lang/rust#54236
  • Loading branch information
oconnor663 committed Sep 24, 2018
1 parent 2bc3c52 commit 7418941
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ arrayvec = { version = "0.4.7", default-features = false, features = ["use_union
byteorder = { version = "1.2.4", default-features = false }
blake2b_simd = { version = "0.2.3", default-features = false }
constant_time_eq = "0.1.3"
copy_in_place = "0.2.0"
rayon = { version = "1.0.2", optional = true }

[dev-dependencies]
Expand Down
3 changes: 1 addition & 2 deletions src/decode.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use arrayvec::ArrayVec;
use constant_time_eq::constant_time_eq;
use copy_in_place::copy_in_place;
#[cfg(feature = "std")]
use rayon;

Expand Down Expand Up @@ -147,7 +146,7 @@ fn extract_in_place(
if content_len <= CHUNK_SIZE {
// This function might eventually make its way into libcore:
// https://github.com/rust-lang/rust/pull/53652
copy_in_place(buf, read_offset..read_offset + content_len, write_offset);
buf.copy_within(read_offset..read_offset + content_len, write_offset);
} else {
read_offset += PARENT_SIZE;
let left_len = hash::left_len(content_len as u64) as usize;
Expand Down
3 changes: 1 addition & 2 deletions src/encode.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use arrayvec::ArrayVec;
use blake2b_simd;
use copy_in_place::copy_in_place;
use core::cmp;
use core::fmt;
use hash::Finalization::{self, NotRoot, Root};
Expand Down Expand Up @@ -198,7 +197,7 @@ fn layout_chunks_in_place(
content_len: usize,
) {
if content_len <= CHUNK_SIZE {
copy_in_place(buf, read_offset..read_offset + content_len, write_offset);
buf.copy_within(read_offset..read_offset + content_len, write_offset);
} else {
let left_len = hash::left_len(content_len as u64) as usize;
let left_write_offset = write_offset + PARENT_SIZE;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(copy_within)]

#[cfg(feature = "std")]
extern crate core;
Expand All @@ -9,7 +10,6 @@ extern crate arrayvec;
extern crate blake2b_simd;
extern crate byteorder;
extern crate constant_time_eq;
extern crate copy_in_place;
#[cfg(feature = "std")]
extern crate rayon;

Expand Down

0 comments on commit 7418941

Please sign in to comment.