Skip to content

Commit

Permalink
Merge #175
Browse files Browse the repository at this point in the history
175: Delete copy_memory function r=Dylan-DPC a=kinggoesgaming

<!--
    As we are working towards a stable version of uuid, we require that you 
    open an issue, before submitting a pull request. If the pull request is 
    imcomplete, prepend the Title with WIP: 
-->

**I'm submitting a ...**
  - [ ] bug fix
  - [ ] feature enhancement
  - [x] deprecation or removal
  - [x] refactor

# Description
Replace `uuid::copy_memory` with `<[_]>::copy_from_slice`

# Motivation
`core` already provides a good optimized version of `slice` copying function, so we dont need to create our own duplicate code.

# Tests
Our tests and benchmarks are running good, other than one or two runs which suggest a 1-2 nanosecond slowdown.

# Related Issue(s)
#173
  • Loading branch information
bors[bot] committed Mar 19, 2018
2 parents 4c562db + 3533e5d commit eca7598
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl Uuid {
hash.update(name.as_bytes());
let buffer = hash.digest().bytes();
let mut uuid = Uuid { bytes: [0; 16] };
copy_memory(&mut uuid.bytes, &buffer[..16]);
uuid.bytes.copy_from_slice(&buffer[..16]);
uuid.set_variant(UuidVariant::RFC4122);
uuid.set_version(UuidVersion::Sha1);
uuid
Expand Down Expand Up @@ -647,7 +647,7 @@ impl Uuid {
}

let mut uuid = Uuid { bytes: [0; 16] };
copy_memory(&mut uuid.bytes, b);
uuid.bytes.copy_from_slice(b);
Ok(uuid)
}

Expand Down Expand Up @@ -992,12 +992,6 @@ impl Uuid {
}
}

fn copy_memory(dst: &mut [u8], src: &[u8]) {
for (slot, val) in dst.iter_mut().zip(src.iter()) {
*slot = *val;
}
}

impl Default for Uuid {
/// Returns the nil UUID, which is all zeroes
fn default() -> Uuid {
Expand Down

0 comments on commit eca7598

Please sign in to comment.