lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I test four size of 'tt_' with each struct assign method, the result is amazing.

#define setobj_X(L,obj1,obj2) \
  { TValue *io1=(obj1); *io1 = *(obj2); \
         (void)L; checkliveness(L,io1); }

#define setobj_Y(L,obj1,obj2) \
  { TValue *io1=(obj1); const TValue *io2=(obj2); \
     io1->value_ = io2->value_; io1->tt_ = io2->tt_; \
     (void)L; checkliveness(L,io1); }


 typeof(tt_)    char       short        int         long

 setobj_X     0.55s      0.55s       0.55s    0.41s

 setobj_Y     0.52s      0.43s       0.42s    0.42s

云风 Cloud Wu <cloudwu@gmail.com> 于2019年6月14日周五 下午6:16写道:

Because the sizeof(TValue) is 16 bytes on 64 bit platform, but
sizeof(obj->value_) + sizeof(obj->tt_) is 9 bytes.

--
http://blog.codingnow.com