Project

General

Profile

Feature #10585 ยป 0002-struct.c-cache-member-definition-in-a-subclass.patch

0002-with-NIL_P - funny_falcon (Yura Sokolov), 12/15/2014 06:28 PM

View differences:

struct.c
24 24
static inline VALUE
25 25
struct_ivar_get(VALUE c, ID id)
26 26
{
27
    for (;;) {
28
	if (rb_ivar_defined(c, id))
29
	    return rb_ivar_get(c, id);
30
	c = RCLASS_SUPER(c);
31
	if (c == 0 || c == rb_cStruct)
32
	    return Qnil;
27
    VALUE orig = c;
28
    VALUE ivar = rb_attr_get(c, id);
29
    if (!NIL_P(ivar))
30
	return ivar;
31
    for(;;) {
32
        c = RCLASS_SUPER(c);
33
        if (c == 0 || c == rb_cStruct)
34
            return Qnil;
35
	ivar = rb_attr_get(c, id);
36
	if (!NIL_P(ivar)) {
37
            rb_ivar_set(orig, id, ivar);
38
            return ivar;
39
        }
33 40
    }
34 41
}
35 42

  
36
-