Is this redundant?

Jack Yi piziyi at gmail.com
Sun Nov 16 18:23:36 CET 2008


Hi, guys,I'm a newbie, If I'm wrong, please forgive me.
Please look at the following code (mpz/and.c):
void
mpz_and (mpz_ptr res, mpz_srcptr op1, mpz_srcptr op2)
{
  mp_srcptr op1_ptr, op2_ptr;
  mp_size_t op1_size, op2_size;
  mp_ptr res_ptr;
  mp_size_t res_size;
  mp_size_t i;
  TMP_DECL;
  TMP_MARK;
  op1_size = op1->_mp_size;
  op2_size = op2->_mp_size;
  op1_ptr = op1->_mp_d;
  op2_ptr = op2->_mp_d;
  res_ptr = res->_mp_d;
  if (op1_size >= 0)
    {
      if (op2_size >= 0)
 {
   res_size = MIN (op1_size, op2_size);
   /* First loop finds the size of the result.  */
   for (i = res_size - 1; i >= 0; i--)
     if ((op1_ptr[i] & op2_ptr[i]) != 0)
       break;
   res_size = i + 1;
   /* Handle allocation, now then we know exactly how much space is
      needed for the result.  */
   if (UNLIKELY (res->_mp_alloc < res_size))
     {
       _mpz_realloc (res, res_size);
       op1_ptr = op1->_mp_d;
       op2_ptr = op2->_mp_d;
      //** nobody modified op1_ptr,op1->_mp_d,op2_ptr,op2->_mp_d. Why do we
need to this again?
       res_ptr = res->_mp_d;
     }
   res->_mp_size = res_size;
          if (LIKELY (res_size != 0))
            mpn_and_n (res_ptr, op1_ptr, op2_ptr, res_size);
   return;
 }
      else /* op2_size < 0 */
 {
   /* Fall through to the code at the end of the function.  */
 }
    }
  else
{
....
{


....
}

I think it is redundant.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gmplib.org/list-archives/gmp-discuss/attachments/20081117/fade45a6/attachment.html 


More information about the gmp-discuss mailing list