From 7418941d712a46f5be751dbb47778eb17aa90535 Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Mon, 24 Sep 2018 15:46:58 -0400 Subject: [PATCH] try out the unstable copy_within interface 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: https://github.com/rust-lang/rust/issues/54236 --- Cargo.toml | 1 - src/decode.rs | 3 +-- src/encode.rs | 3 +-- src/lib.rs | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b0af8c7..ab55d19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/src/decode.rs b/src/decode.rs index 04da75d..533b0cf 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -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; @@ -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; diff --git a/src/encode.rs b/src/encode.rs index 3ebf352..ce89b62 100644 --- a/src/encode.rs +++ b/src/encode.rs @@ -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}; @@ -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; diff --git a/src/lib.rs b/src/lib.rs index 7ea4566..2b696f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ #![cfg_attr(not(feature = "std"), no_std)] +#![feature(copy_within)] #[cfg(feature = "std")] extern crate core; @@ -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;