Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Move some #18 issues to #30, #31, one minor "improvement"
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Feb 24, 2016
1 parent c94d0d3 commit 804068c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/detail/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub const BYTES: usize = 32;
const BYTES_U8: u8 = BYTES as u8;


// #0018: when simd is stable, it could be used
// #0031: when simd is stable, it could be used
// use simd::u8x16;
/// A convenient way to manage and manipulate a checksum.
///
Expand Down Expand Up @@ -49,12 +49,9 @@ impl Sum {
pub fn load(arr: &[u8]) -> Sum {
assert_eq!(arr.len(), BYTES);
// Sum { s1: u8x16::load(&arr, 0), s2: u8x16::load(&arr, 16) }
// #0018 : how to do a fixed-size array copy?
let mut result = Sum::zero();
for i in 0..BYTES {
result.s[i] = arr[i];
}
result
let mut s = [0u8; BYTES];
s.clone_from_slice(arr);
Sum{ s: s }
}

/// Write the checksum bytes to a stream
Expand Down Expand Up @@ -127,7 +124,7 @@ const HEX_CHARS : &'static [u8; 16] = b"0123456789ABCDEF";
impl<'a> ops::BitXor for &'a Sum {
type Output = Sum;
fn bitxor(self, rhs: &'a Sum) -> Sum {
// #0018: optimise XOR operation
// #0031: optimise XOR operation
let mut result = Sum::zero();
for i in 0..BYTES {
result.s[i] = self.s[i] ^ rhs.s[i];
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a> fmt::Display for ByteFormatter<'a> {
} else if *b == b'\'' {
try!(write!(f, "\\\'"));
} else if *b >= b' ' && *b <= b'~' {
// TODO: this is a horrible way to write a char!
// #0030: this is a horrible way to write a char!
let v = vec![*b];
try!(write!(f, "{}", from_utf8(&v).unwrap()));
} else {
Expand Down

0 comments on commit 804068c

Please sign in to comment.