Skip to content

Commit

Permalink
sha2 -- introduce locals to clarify which subportions are being borrowed
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Feb 11, 2014
1 parent 8dff89c commit b0ac40a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/librustc/util/sha2.rs
Expand Up @@ -453,18 +453,20 @@ impl Engine256 {
assert!(!self.finished)
// Assumes that input.len() can be converted to u64 without overflow
self.length_bits = add_bytes_to_bits(self.length_bits, input.len() as u64);
self.buffer.input(input, |input: &[u8]| { self.state.process_block(input) });
let self_state = &mut self.state;
self.buffer.input(input, |input: &[u8]| { self_state.process_block(input) });
}

fn finish(&mut self) {
if self.finished {
return;
}

self.buffer.standard_padding(8, |input: &[u8]| { self.state.process_block(input) });
let self_state = &mut self.state;
self.buffer.standard_padding(8, |input: &[u8]| { self_state.process_block(input) });
write_u32_be(self.buffer.next(4), (self.length_bits >> 32) as u32 );
write_u32_be(self.buffer.next(4), self.length_bits as u32);
self.state.process_block(self.buffer.full_buffer());
self_state.process_block(self.buffer.full_buffer());

self.finished = true;
}
Expand Down

0 comments on commit b0ac40a

Please sign in to comment.