summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/marshal.c b/marshal.c
index 3b7f79d614..8bc80194c0 100644
--- a/marshal.c
+++ b/marshal.c
@@ -637,16 +637,9 @@ w_ivar(st_index_t num, VALUE ivobj, VALUE encname, struct dump_call_arg *arg)
static void
w_objivar(VALUE obj, struct dump_call_arg *arg)
{
- VALUE *ptr;
- long i, len, num;
-
- len = ROBJECT_NUMIV(obj);
- ptr = ROBJECT_IVPTR(obj);
- num = 0;
- for (i = 0; i < len; i++)
- if (ptr[i] != Qundef)
- num += 1;
+ st_data_t num = 0;
+ rb_ivar_foreach(obj, obj_count_ivars, (st_data_t)&num);
w_long(num, arg->arg);
if (num != 0) {
rb_ivar_foreach(obj, w_obj_each, (st_data_t)arg);