Module: libav
Branch: master
Commit: 669bbedfa863f8a1491a186fac4238baba407037

Author:    Luca Barbato <lu_z...@gentoo.org>
Committer: Luca Barbato <lu_z...@gentoo.org>
Date:      Thu Jul  5 09:50:59 2012 +0200

blowfish: invert branch and loop precedence

Should slightly improve performance depending on the compiler used.

---

 libavutil/blowfish.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/libavutil/blowfish.c b/libavutil/blowfish.c
index b7f5294..554953e 100644
--- a/libavutil/blowfish.c
+++ b/libavutil/blowfish.c
@@ -381,8 +381,8 @@ void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, const 
uint8_t *src,
     uint32_t v0, v1;
     int i;
 
-    while (count > 0) {
-        if (decrypt) {
+    if (decrypt) {
+        while (count > 0) {
             v0 = AV_RB32(src);
             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];
                 memcpy(iv, src, 8);
             }
-        } else {
+
+            src   += 8;
+            dst   += 8;
+            count -= 8;
+        }
+    } else {
+        while (count > 0) {
             if (iv) {
                 for (i = 0; i < 8; i++)
                     dst[i] = src[i] ^ iv[i];
@@ -414,11 +420,11 @@ void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, 
const uint8_t *src,
 
             if (iv)
                 memcpy(iv, dst, 8);
-        }
 
-        src   += 8;
-        dst   += 8;
-        count -= 8;
+            src   += 8;
+            dst   += 8;
+            count -= 8;
+        }
     }
 }
 

_______________________________________________
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to