Branch: Tag:

2016-04-17

2016-04-17 18:29:39 by Martin Nilsson <nilsson@fastmail.com>

Fixed the early out when random limit is 2^x and !(x%8). Also some document fixes.

699:   static void mpzmod_get_string(INT32 args)   {    DECLARE_THIS(); -  /* Also called as json_encode (with some arguments). */ +  /* Also called as encode_json (with some arguments). */    pop_n_elems(args);    push_string(low_get_mpz_digits(THIS, 10));   }
707:   /*! @decl string digits(void|int(2..62)|int(256..256)|int(-256..-256) base)    *!    *! Convert this mpz object to a string. If a @[base] is given the -  *! number will be represented in that base. Valid bases are 2-36 and +  *! number will be represented in that base. Valid bases are 2-62 and    *! @expr{256@} and @expr{-256@}. The default base is 10.    *! -  +  *! @note +  *! The bases 37 to 62 are not available When compiled with GMP +  *! earlier than version 5.    *! @seealso    *! @[cast_to_string]    */
2050:    MP_INT *mpz_res;    unsigned bits, bytes;    mp_limb_t mask; -  int i; +  int i, fast=0;    DECLARE_THIS();       /* NB: Nominally we could survive with just one argument too, but... */
2092:    if (!(bits & 0x07)) {    /* One less byte of random data needed. */    bytes--; +  fast=1;    }    }   
2117:    mpz_import(mpz_res, bytes, 1, 1, 0, 0, sp[-1].u.string->str);    pop_stack();    -  if (bits > (bytes<<3)) { +  if (fast) {    /* We've decreased the number of bytes above.    * Ie we have the special case of an even number of random bytes.    */