blowfish: invert branch and loop precedence

Should slightly improve performance depending on the compiler used.
This commit is contained in:
Luca Barbato 2012-07-05 09:50:59 +02:00
parent 5b54a90c8b
commit 669bbedfa8

View file

@ -381,8 +381,8 @@ void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
uint32_t v0, v1; uint32_t v0, v1;
int i; int i;
while (count > 0) {
if (decrypt) { if (decrypt) {
while (count > 0) {
v0 = AV_RB32(src); v0 = AV_RB32(src);
v1 = AV_RB32(src + 4); v1 = AV_RB32(src + 4);
@ -396,7 +396,13 @@ void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
dst[i] = dst[i] ^ iv[i]; dst[i] = dst[i] ^ iv[i];
memcpy(iv, src, 8); memcpy(iv, src, 8);
} }
src += 8;
dst += 8;
count -= 8;
}
} else { } else {
while (count > 0) {
if (iv) { if (iv) {
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
dst[i] = src[i] ^ iv[i]; dst[i] = src[i] ^ iv[i];
@ -414,12 +420,12 @@ void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
if (iv) if (iv)
memcpy(iv, dst, 8); memcpy(iv, dst, 8);
}
src += 8; src += 8;
dst += 8; dst += 8;
count -= 8; count -= 8;
} }
}
} }
#ifdef TEST #ifdef TEST