mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
4ce28b58cb
commit
e082f41611
Notes:
git
2019-12-31 22:48:53 +09:00
Merged-By: mrkn <mrkn@ruby-lang.org>
3 changed files with 17 additions and 9 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue