Commit 91ba9ba7 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2786 from furunkel/set_value

Avoid unnecessary stores and reloads
parents 06287783 99a00cf4
......@@ -61,7 +61,6 @@ typedef struct mrb_value {
#define mrb_symbol(o) (o).value.sym
#define BOXNAN_SET_VALUE(o, tt, attr, v) do {\
(o).value.ttt = (0xfff00000|(((tt)+1)<<14));\
switch (tt) {\
case MRB_TT_FALSE:\
case MRB_TT_TRUE:\
......@@ -70,6 +69,7 @@ typedef struct mrb_value {
case MRB_TT_SYMBOL: (o).attr = (v); break;\
default: (o).value.i = 0; (o).value.p = (void*)((uintptr_t)(o).value.p | (((uintptr_t)(v))>>2)); break;\
}\
(o).value.ttt = (0xfff00000|(((tt)+1)<<14));\
} while (0)
#define SET_FLOAT_VALUE(mrb,r,v) do { \
......
......@@ -92,15 +92,13 @@ mrb_type(mrb_value o)
#define mrb_nil_p(o) ((o).w == MRB_Qnil)
#define BOXWORD_SET_VALUE(o, ttt, attr, v) do {\
(o).w = 0;\
(o).attr = (v);\
switch (ttt) {\
case MRB_TT_FALSE: (o).w = (v) ? MRB_Qfalse : MRB_Qnil; break;\
case MRB_TT_TRUE: (o).w = MRB_Qtrue; break;\
case MRB_TT_UNDEF: (o).w = MRB_Qundef; break;\
case MRB_TT_FIXNUM: (o).value.i_flag = MRB_FIXNUM_FLAG; break;\
case MRB_TT_SYMBOL: (o).value.sym_flag = MRB_SYMBOL_FLAG; break;\
default: if ((o).value.bp) (o).value.bp->tt = ttt; break;\
case MRB_TT_FIXNUM: (o).value.i_flag = MRB_FIXNUM_FLAG; (o).attr = (v); break;\
case MRB_TT_SYMBOL: (o).value.sym_flag = MRB_SYMBOL_FLAG; (o).attr = (v); break;\
default: (o).w = 0; (o).attr = (v); if ((o).value.bp) (o).value.bp->tt = ttt; break;\
}\
} while (0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment