diff options
Diffstat (limited to 'libtommath/bn_mp_div_d.c')
-rw-r--r-- | libtommath/bn_mp_div_d.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libtommath/bn_mp_div_d.c b/libtommath/bn_mp_div_d.c index d64b4b5..6a26d4f 100644 --- a/libtommath/bn_mp_div_d.c +++ b/libtommath/bn_mp_div_d.c @@ -19,7 +19,12 @@ static int s_is_power_of_two(mp_digit b, int *p) { int x; - for (x = 1; x < DIGIT_BIT; x++) { + /* fast return if no power of two */ + if ((b==0) || (b & (b-1))) { + return 0; + } + + for (x = 0; x < DIGIT_BIT; x++) { if (b == (((mp_digit)1)<<x)) { *p = x; return 1; @@ -106,5 +111,5 @@ int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d) #endif /* $Source: /cvs/libtom/libtommath/bn_mp_div_d.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2007/01/09 04:44:32 $ */ |