diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2013-02-14 12:34:45 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2013-02-14 12:34:45 +0100 |
commit | 48b1ce2036adb2a53e09e7a87efcbb2c48c4976b (patch) | |
tree | d67791173a184dafceb9b712cefebae41d18259a /mpz/ior.c | |
parent | 0f467c04d5940f1171e2672c66b96347cd081824 (diff) | |
download | gmp-48b1ce2036adb2a53e09e7a87efcbb2c48c4976b.tar.gz |
mpz/ior.c: Use macros: MPZ_REALLOC and MPN_INCR_U.
Diffstat (limited to 'mpz/ior.c')
-rw-r--r-- | mpz/ior.c | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -47,10 +47,9 @@ mpz_ior (mpz_ptr res, mpz_srcptr op1, mpz_srcptr op2) { if (ALLOC(res) < op1_size) { - _mpz_realloc (res, op1_size); + res_ptr = MPZ_REALLOC (res, op1_size); /* No overlapping possible: op1_ptr = PTR(op1); */ op2_ptr = PTR(op2); - res_ptr = PTR(res); } if (res_ptr != op1_ptr) @@ -64,10 +63,9 @@ mpz_ior (mpz_ptr res, mpz_srcptr op1, mpz_srcptr op2) { if (ALLOC(res) < op2_size) { - _mpz_realloc (res, op2_size); + res_ptr = MPZ_REALLOC (res, op2_size); op1_ptr = PTR(op1); /* No overlapping possible: op2_ptr = PTR(op2); */ - res_ptr = PTR(res); } if (res_ptr != op2_ptr) @@ -120,17 +118,14 @@ mpz_ior (mpz_ptr res, mpz_srcptr op1, mpz_srcptr op2) if (res_size != 0) { - res_ptr = MPZ_REALLOC (res, res_size + 1); + res_ptr = MPZ_NEWALLOC (res, res_size + 1); /* Second loop computes the real result. */ mpn_and_n (res_ptr, op1_ptr, op2_ptr, res_size); - cy = mpn_add_1 (res_ptr, res_ptr, res_size, (mp_limb_t) 1); - if (cy) - { - res_ptr[res_size] = cy; - res_size++; - } + res_ptr[res_size] = 0; + MPN_INCR_U (res_ptr, res_size + 1, 1); + res_size += res_ptr[res_size]; } else { |