1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Introduce RVALUE_EMBED_LEN_MAX to remove a magic number

* include/ruby/ruby.h: replace a magic number with RVALUE_EMBED_LEN_MAX,
  which indicates the number of VALUE elements can be embedded in a RVALUE.

* internal.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mrkn 2019-02-14 15:29:04 +00:00
parent cb57336e86
commit 7570864267
2 changed files with 11 additions and 6 deletions

View file

@ -903,10 +903,15 @@ VALUE rb_obj_reveal(VALUE obj, VALUE klass); /* do not use this API to change kl
#define RBASIC_CLASS(obj) (RBASIC(obj)->klass)
#define RVALUE_EMBED_LEN_MAX RVALUE_EMBED_LEN_MAX
enum ruby_rvalue_flags {
RVALUE_EMBED_LEN_MAX = 3,
};
#define ROBJECT_EMBED_LEN_MAX ROBJECT_EMBED_LEN_MAX
#define ROBJECT_EMBED ROBJECT_EMBED
enum ruby_robject_flags {
ROBJECT_EMBED_LEN_MAX = 3,
ROBJECT_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX,
ROBJECT_EMBED = RUBY_FL_USER1,
ROBJECT_ENUM_END
@ -972,7 +977,7 @@ enum ruby_rstring_flags {
RSTRING_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|
RUBY_FL_USER5|RUBY_FL_USER6),
RSTRING_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+2),
RSTRING_EMBED_LEN_MAX = (int)((sizeof(VALUE)*3)/sizeof(char)-1),
RSTRING_EMBED_LEN_MAX = (int)((sizeof(VALUE)*RVALUE_EMBED_LEN_MAX)/sizeof(char)-1),
RSTRING_FSTR = RUBY_FL_USER17,
RSTRING_ENUM_END
@ -1018,7 +1023,7 @@ struct RString {
#endif
enum ruby_rarray_flags {
RARRAY_EMBED_LEN_MAX = 3,
RARRAY_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX,
RARRAY_EMBED_FLAG = RUBY_FL_USER1,
/* RUBY_FL_USER2 is for ELTS_SHARED */
RARRAY_EMBED_LEN_MASK = (RUBY_FL_USER4|RUBY_FL_USER3),

View file

@ -673,8 +673,8 @@ rb_fix_mod_fix(VALUE x, VALUE y)
#define BIGNUM_EMBED_LEN_NUMBITS 3
#ifndef BIGNUM_EMBED_LEN_MAX
# if (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
# define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT)
# if (SIZEOF_VALUE*RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
# define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*RVALUE_EMBED_LEN_MAX/SIZEOF_ACTUAL_BDIGIT)
# else
# define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
# endif
@ -830,7 +830,7 @@ extern void ruby_init_setproctitle(int argc, char *argv[]);
#define RSTRUCT_EMBED_LEN_SHIFT RSTRUCT_EMBED_LEN_SHIFT
enum {
RSTRUCT_EMBED_LEN_MAX = 3,
RSTRUCT_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX,
RSTRUCT_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER1),
RSTRUCT_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+1),
RSTRUCT_TRANSIENT_FLAG = FL_USER3,