Changeset 30581 in project


Ignore:
Timestamp:
03/18/14 20:42:15 (7 years ago)
Author:
sjamaan
Message:

numbers: simplify and inline shorten_bignum into bignum_add_unsigned, then remove it; it was only used in one place and a bit silly because we always know the target bignum is one smaller, because the allocation allowed for a carry

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/numbers/trunk/numbers-c.c

    r29588 r30581  
    11/* numbers-c.c
    22 *
    3  * Copyright 2010-2013 The CHICKEN Team
     3 * Copyright 2010-2014 The CHICKEN Team
    44 *
    55 * This contains a barely recognizable version of c/bignum.c from Scheme48 1.8:
     
    274274
    275275static bignum_type
    276 bignum_shorten_length(bignum_type bignum, bignum_length_type length)
    277 {
    278   bignum_length_type current_length = (BIGNUM_LENGTH (bignum));
    279   BIGNUM_ASSERT ((length >= 0) || (length <= current_length));
    280   if (length < current_length)
    281     {
    282       BIGNUM_SET_HEADER
    283         (bignum, length, ((length != 0) && (BIGNUM_NEGATIVE_P (bignum))));
    284       BIGNUM_REDUCE_LENGTH (bignum, bignum, length);
    285     }
    286   return bignum;
    287 }
    288 
    289 static bignum_type
    290276bignum_trim(bignum_type bignum)
    291277{
     
    781767        (*scan_r++) = (*scan_x++);
    782768    }
    783     if (carry != 0)
    784       {
    785         (*scan_r) = 1;
    786         return (r);
    787       }
    788     return (bignum_shorten_length (r, x_length));
     769    if (carry != 0) {
     770      (*scan_r) = 1;
     771    } else { /* r is one word too big (to hold a possible carry), readjust */
     772      BIGNUM_SET_HEADER(r, x_length, negative_p);
     773      BIGNUM_REDUCE_LENGTH(r, r, x_length);
     774    }
     775    return (r);
    789776  }
    790777}
Note: See TracChangeset for help on using the changeset viewer.