summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-07-25 11:32:04 +1000
committerDamien George <damien.p.george@gmail.com>2017-07-25 11:32:04 +1000
commit4d1fb6107fdedb0dda8dfb1491c033bf731222c6 (patch)
treee6b05ae5834ecb3b295fb9c3ee2ddf3ae586d19e
parentaa7be82a4dff59b22763abbe1bd5e74c0e37b453 (diff)
downloadmicropython-4d1fb6107fdedb0dda8dfb1491c033bf731222c6.tar.gz
micropython-4d1fb6107fdedb0dda8dfb1491c033bf731222c6.zip
py/mpz: Make mpz_is_zero() an inline function.
It's more efficient as an inline function, and saves code size.
-rw-r--r--py/mpz.c4
-rw-r--r--py/mpz.h2
2 files changed, 1 insertions, 5 deletions
diff --git a/py/mpz.c b/py/mpz.c
index f5675a2917..80473df882 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -939,10 +939,6 @@ void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byte *buf)
z->len = mpn_remove_trailing_zeros(z->dig, z->dig + z->len);
}
-bool mpz_is_zero(const mpz_t *z) {
- return z->len == 0;
-}
-
#if 0
these functions are unused
diff --git a/py/mpz.h b/py/mpz.h
index 878febf8b4..2ff404ffa8 100644
--- a/py/mpz.h
+++ b/py/mpz.h
@@ -111,7 +111,7 @@ void mpz_set_from_float(mpz_t *z, mp_float_t src);
size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, bool neg, unsigned int base);
void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byte *buf);
-bool mpz_is_zero(const mpz_t *z);
+static inline bool mpz_is_zero(const mpz_t *z) { return z->len == 0; }
int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs);
void mpz_abs_inpl(mpz_t *dest, const mpz_t *z);