Project

General

Profile

Feature #10585 » 0001-struct.c-speedup-struct.name-v-for-small-structs.patch

funny_falcon (Yura Sokolov), 12/10/2014 02:31 PM

View differences:

struct.c
}
static VALUE
rb_struct_set(VALUE obj, long i, VALUE val)
{
if (i >= RSTRUCT_LEN(obj)) {
rb_raise(rb_eTypeError, "corrupted struct");
}
rb_struct_modify(obj);
RSTRUCT_SET(obj, i, val);
return val;
}
static VALUE rb_struct_set0(VALUE obj, VALUE val) {return rb_struct_set(obj, 0, val);}
static VALUE rb_struct_set1(VALUE obj, VALUE val) {return rb_struct_set(obj, 1, val);}
static VALUE rb_struct_set2(VALUE obj, VALUE val) {return rb_struct_set(obj, 2, val);}
static VALUE rb_struct_set3(VALUE obj, VALUE val) {return rb_struct_set(obj, 3, val);}
static VALUE rb_struct_set4(VALUE obj, VALUE val) {return rb_struct_set(obj, 4, val);}
static VALUE rb_struct_set5(VALUE obj, VALUE val) {return rb_struct_set(obj, 5, val);}
static VALUE rb_struct_set6(VALUE obj, VALUE val) {return rb_struct_set(obj, 6, val);}
static VALUE rb_struct_set7(VALUE obj, VALUE val) {return rb_struct_set(obj, 7, val);}
static VALUE rb_struct_set8(VALUE obj, VALUE val) {return rb_struct_set(obj, 8, val);}
static VALUE rb_struct_set9(VALUE obj, VALUE val) {return rb_struct_set(obj, 9, val);}
#define N_SET_FUNC numberof(ref_func)
static VALUE (*const set_func[])(VALUE, VALUE) = {
rb_struct_set0,
rb_struct_set1,
rb_struct_set2,
rb_struct_set3,
rb_struct_set4,
rb_struct_set5,
rb_struct_set6,
rb_struct_set7,
rb_struct_set8,
rb_struct_set9,
};
static VALUE
anonymous_struct(VALUE klass)
{
VALUE nstr;
......
else {
define_aref_method(nstr, ptr_members[i], off);
}
define_aset_method(nstr, ID2SYM(rb_id_attrset(id)), off);
if (i < N_SET_FUNC) {
rb_define_method_id(nstr, rb_id_attrset(id), set_func[i], 1);
}
else {
define_aset_method(nstr, ID2SYM(rb_id_attrset(id)), off);
}
}
return nstr;
(1-1/5)