diff options
author | lloyd <[email protected]> | 2010-10-13 13:24:01 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-10-13 13:24:01 +0000 |
commit | bb53c6169463a67cc751625cb0a2c47df129a2ab (patch) | |
tree | 762822f19139db7f8198f21ab59043100f204ba8 /src | |
parent | 9dc1fe2b5ca62adc2da69e1b55d9fa880833b2ca (diff) |
Use buffer.size() directly to avoid lots of virtual calls in core loop
Diffstat (limited to 'src')
-rw-r--r-- | src/hash/mdx_hash/mdx_hash.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/hash/mdx_hash/mdx_hash.cpp b/src/hash/mdx_hash/mdx_hash.cpp index 84b97fd7f..f82c971f8 100644 --- a/src/hash/mdx_hash/mdx_hash.cpp +++ b/src/hash/mdx_hash/mdx_hash.cpp @@ -50,22 +50,22 @@ void MDx_HashFunction::add_data(const byte input[], size_t length) { buffer.copy(position, input, length); - if(position + length >= hash_block_size()) + if(position + length >= buffer.size()) { compress_n(&buffer[0], 1); - input += (hash_block_size() - position); - length -= (hash_block_size() - position); + input += (buffer.size() - position); + length -= (buffer.size() - position); position = 0; } } - const size_t full_blocks = length / hash_block_size(); - const size_t remaining = length % hash_block_size(); + const size_t full_blocks = length / buffer.size(); + const size_t remaining = length % buffer.size(); if(full_blocks) compress_n(input, full_blocks); - buffer.copy(position, input + full_blocks * hash_block_size(), remaining); + buffer.copy(position, input + full_blocks * buffer.size(), remaining); position += remaining; } @@ -75,16 +75,16 @@ void MDx_HashFunction::add_data(const byte input[], size_t length) void MDx_HashFunction::final_result(byte output[]) { buffer[position] = (BIG_BIT_ENDIAN ? 0x80 : 0x01); - for(size_t i = position+1; i != hash_block_size(); ++i) + for(size_t i = position+1; i != buffer.size(); ++i) buffer[i] = 0; - if(position >= hash_block_size() - COUNT_SIZE) + if(position >= buffer.size() - COUNT_SIZE) { compress_n(&buffer[0], 1); zeroise(buffer); } - write_count(&buffer[hash_block_size() - COUNT_SIZE]); + write_count(&buffer[buffer.size() - COUNT_SIZE]); compress_n(&buffer[0], 1); copy_out(output); |