Optimize bn_correct_top.
authorAndy Polyakov <appro@openssl.org>
Wed, 15 Oct 2008 10:48:52 +0000 (10:48 +0000)
committerAndy Polyakov <appro@openssl.org>
Wed, 15 Oct 2008 10:48:52 +0000 (10:48 +0000)
crypto/bn/bn.h

index 4749c52..dc0debb 100644 (file)
@@ -752,10 +752,12 @@ int RAND_pseudo_bytes(unsigned char *buf,int num);
 #define bn_correct_top(a) \
         { \
         BN_ULONG *ftl; \
-       if ((a)->top > 0) \
+       int top = (a)->top; \
+       if (top > 0) \
                { \
-               for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
-               if (*(ftl--)) break; \
+               for (ftl= &((a)->d[top-1]); top > 0; top--) \
+                       if (*(ftl--)) break; \
+               (a)->top = top; \
                } \
        bn_pollute(a); \
        }