Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use int instead of char for flag variables
The char type can be equivalent to either signed char or unsigned char. If the latter, assigning -1 to endian in GMPy_MPZ_Method_From_Bytes actually stores the value 255, a positive value. This leads to incorrect conversions, manifesting as failure of test_mpz_from_bytes. Using char doesn't save any space, since local variables are stored in 32- or 64-bit CPU registers, or in 32-bit aligned stack slots. Also, using char instead of int generates less efficient code. Modern 64-bit processors are optimized for 64- and 32-bit quantities. Operating on 8-bit quantities takes more clock cycles. Finally, negative values cannot be stored safely in char variables due to implicit conversion to positive values of platforms where char == unsigned char.
- Loading branch information