summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
Diffstat (limited to 'range.c')
-rw-r--r--range.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/range.c b/range.c
index 6d6a528..280c333 100644
--- a/range.c
+++ b/range.c
@@ -27,7 +27,12 @@ static ID id_cmp, id_succ, id_beg, id_end, id_excl, id_integer_p, id_div;
#define RANGE_EXCL(r) (RSTRUCT(r)->as.ary[2])
#define EXCL(r) RTEST(RANGE_EXCL(r))
-#define SET_EXCL(r,v) (RSTRUCT(r)->as.ary[2] = (v) ? Qtrue : Qfalse)
+static inline VALUE
+SET_EXCL(VALUE r, VALUE v)
+{
+ RSTRUCT_SET(r, 2, v);
+ return v ? Qtrue : Qfalse;
+}
static VALUE
range_failed(void)
@@ -59,8 +64,8 @@ range_init(VALUE range, VALUE beg, VALUE end, int exclude_end)
}
SET_EXCL(range, exclude_end);
- RSTRUCT(range)->as.ary[0] = beg;
- RSTRUCT(range)->as.ary[1] = end;
+ RSTRUCT_SET(range, 0, beg);
+ RSTRUCT_SET(range, 1, end);
}
VALUE
@@ -1228,9 +1233,9 @@ range_loader(VALUE range, VALUE obj)
rb_raise(rb_eTypeError, "not a dumped range object");
}
- RSTRUCT(range)->as.ary[0] = rb_ivar_get(obj, id_beg);
- RSTRUCT(range)->as.ary[1] = rb_ivar_get(obj, id_end);
- RSTRUCT(range)->as.ary[2] = rb_ivar_get(obj, id_excl);
+ RSTRUCT_SET(range, 0, rb_ivar_get(obj, id_beg));
+ RSTRUCT_SET(range, 1, rb_ivar_get(obj, id_end));
+ RSTRUCT_SET(range, 2, rb_ivar_get(obj, id_excl));
return range;
}