Skip to content

Commit

Permalink
Avoid computing _PyHASH_MODULUS in GMPy_MPQ_Hash_Slot()
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Nov 2, 2023
1 parent 21ccbf7 commit 2e96fb6
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/gmpy2_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ GMPy_MPQ_Hash_Slot(MPQ_Object *self)
mpz_init(temp);
mpz_init(temp1);
mpz_init(mask);
mpz_set_si(mask, 1);
mpz_mul_2exp(mask, mask, _PyHASH_BITS);
mpz_sub_ui(mask, mask, 1);
mpz_set_si(mask, _PyHASH_MODULUS);

if (!mpz_invert(temp, mpq_denref(self->q), mask)) {
mpz_clear(temp);
Expand Down

0 comments on commit 2e96fb6

Please sign in to comment.