ruby-changes:54871
From: mrkn <ko1@a...>
Date: Fri, 15 Feb 2019 00:29:08 +0900 (JST)
Subject: [ruby-changes:54871] mrkn:r67076 (trunk): Introduce RVALUE_EMBED_LEN_MAX to remove a magic number
mrkn 2019-02-15 00:29:04 +0900 (Fri, 15 Feb 2019) New Revision: 67076 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67076 Log: 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. Modified files: trunk/include/ruby/ruby.h trunk/internal.h Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 67075) +++ include/ruby/ruby.h (revision 67076) @@ -903,10 +903,15 @@ VALUE rb_obj_reveal(VALUE obj, VALUE kla https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L903 #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 { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L977 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 { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1023 #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), Index: internal.h =================================================================== --- internal.h (revision 67075) +++ internal.h (revision 67076) @@ -673,8 +673,8 @@ rb_fix_mod_fix(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/internal.h#L673 #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 a https://github.com/ruby/ruby/blob/trunk/internal.h#L830 #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, -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/