diff options
author | Kenta Murata <[email protected]> | 2019-12-31 22:48:23 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-31 22:48:23 +0900 |
commit | e082f41611755b0fde967fccf3174c90ecb8469e (patch) | |
tree | ea496f496836091ff4a2046613b11a112af9fb99 /internal/bignum.h | |
parent | 4ce28b58cbf3f3b5ab0bcd3fa4479d4f6d427158 (diff) |
Introduce BIGNUM_EMBED_P to check BIGNUM_EMBED_FLAG (#2802)
* bignum.h: Add BIGNUM_EMBED_P
* bignum.c: Use macros for handling BIGNUM_EMBED_FLAG
Notes
Notes:
Merged-By: mrkn <[email protected]>
Diffstat (limited to 'internal/bignum.h')
-rw-r--r-- | internal/bignum.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/bignum.h b/internal/bignum.h index c35ba9eb47..508386452c 100644 --- a/internal/bignum.h +++ b/internal/bignum.h @@ -139,6 +139,7 @@ static inline void BIGNUM_NEGATE(VALUE b); static inline size_t BIGNUM_LEN(VALUE b); static inline BDIGIT *BIGNUM_DIGITS(VALUE b); static inline int BIGNUM_LENINT(VALUE b); +static inline bool BIGNUM_EMBED_P(VALUE b); RUBY_SYMBOL_EXPORT_BEGIN /* bignum.c (export) */ @@ -207,7 +208,7 @@ BIGNUM_NEGATE(VALUE b) static inline size_t BIGNUM_LEN(VALUE b) { - if (! FL_TEST_RAW(b, BIGNUM_EMBED_FLAG)) { + if (! BIGNUM_EMBED_P(b)) { return RBIGNUM(b)->as.heap.len; } else { @@ -228,11 +229,18 @@ BIGNUM_LENINT(VALUE b) static inline BDIGIT * BIGNUM_DIGITS(VALUE b) { - if (FL_TEST_RAW(b, BIGNUM_EMBED_FLAG)) { + if (BIGNUM_EMBED_P(b)) { return RBIGNUM(b)->as.ary; } else { return RBIGNUM(b)->as.heap.digits; } } + +static inline bool +BIGNUM_EMBED_P(VALUE b) +{ + return FL_TEST_RAW(b, BIGNUM_EMBED_FLAG); +} + #endif /* INTERNAL_BIGNUM_H */ |