From 305958dbd456d463a92c1fa4c85ceb69a8c7db32 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 7 Oct 2015 19:17:01 +0200 Subject: [PATCH] md5sum: code shrink For CONFIG_MD5_SMALL=1: function old new delta md5_process_block64 925 881 -44 For CONFIG_MD5_SMALL=0: function old new delta md5_process_block64 1603 1586 -17 Signed-off-by: Denys Vlasenko --- libbb/hash_md5_sha.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index 1f63ccdee..d08c6b2f7 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c @@ -137,7 +137,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) #if MD5_SMALL > 0 /* Before we start, one word to the strange constants. They are defined in RFC 1321 as - T[i] = (int)(4294967296.0 * fabs(sin(i))), i=1..64 + T[i] = (int)(2^32 * fabs(sin(i))), i=1..64 */ static const uint32_t C_array[] = { /* round 1 */ @@ -213,7 +213,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) case 2: temp += FH(B, C, D); break; - case 3: + default: /* case 3 */ temp += FI(B, C, D); } temp += words[(int) (*pp++)] + *pc++; @@ -277,10 +277,6 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) #else /* MD5_SMALL == 0 or 1 */ - uint32_t A_save = A; - uint32_t B_save = B; - uint32_t C_save = C; - uint32_t D_save = D; # if MD5_SMALL == 1 const uint32_t *pc; const char *pp; @@ -425,10 +421,10 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) # undef OP # endif /* Add checksum to the starting values */ - ctx->hash[0] = A_save + A; - ctx->hash[1] = B_save + B; - ctx->hash[2] = C_save + C; - ctx->hash[3] = D_save + D; + ctx->hash[0] += A; + ctx->hash[1] += B; + ctx->hash[2] += C; + ctx->hash[3] += D; #endif } #undef FF -- 2.25.1