ObjFW  Diff

Differences From Artifact [8c6a093adf]:

To Artifact [38980867ce]:

  • File src/OFMD5Hash.m — part of check-in [b29adaf0bb] at 2014-09-03 18:53:24 on branch trunk — OFMD5Hash: Optimize by making it more readable

    This has more resemblance to the implementation of the other hashes,
    while the old method had more resemblance to how the algorithm is
    described in the RFC.

    It turns out that Clang generates better code when re-assigning all
    variables to rotate them by one instead of accessing the variables by an
    iteration-dependent index. (user: js, size: 4542) [annotate] [blame] [check-ins using]


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97


98
99
100
101
102
103
104
	new[0] = state[0];
	new[1] = state[1];
	new[2] = state[2];
	new[3] = state[3];

	byteSwapVectorIfBE(buffer, 16);

#define LOOP_BODY(f)							   \
	{								   \
		const uint_fast8_t a = (4 - (i & 3)) & 3;		   \
		const uint_fast8_t b = (a + 1) & 3;			   \
		const uint_fast8_t c = (a + 2) & 3;			   \
		const uint_fast8_t d = (a + 3) & 3;			   \
		const uint_fast8_t r = rotateBits[(i % 4) + (i / 16) * 4]; \
									   \
		new[a] += f(new[b], new[c], new[d]) +			   \
		    buffer[wordOrder[i]] + table[i];			   \
		new[a] = OF_ROL(new[a], r);				   \
		new[a] += new[b];					   \


	}

	for (; i < 16; i++)
		LOOP_BODY(F)
	for (; i < 32; i++)
		LOOP_BODY(G)
	for (; i < 48; i++)







|
|
|
|
<
<
<
<
|
|
|
|
>
>







79
80
81
82
83
84
85
86
87
88
89




90
91
92
93
94
95
96
97
98
99
100
101
102
	new[0] = state[0];
	new[1] = state[1];
	new[2] = state[2];
	new[3] = state[3];

	byteSwapVectorIfBE(buffer, 16);

#define LOOP_BODY(f)							      \
	{								      \
		uint32_t tmp = new[3];					      \
		tmp = new[3];						      \




		new[0] += f(new[1], new[2], new[3]) +			      \
		    buffer[wordOrder[i]] + table[i];			      \
		new[3] = new[2];					      \
		new[2] = new[1];					      \
		new[1] += OF_ROL(new[0], rotateBits[(i % 4) + (i / 16) * 4]); \
		new[0] = tmp;\
	}

	for (; i < 16; i++)
		LOOP_BODY(F)
	for (; i < 32; i++)
		LOOP_BODY(G)
	for (; i < 48; i++)