summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-01 16:18:51 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-01 16:18:51 +0900
commit0b1e26398e018116180bf41cb63887f77d5d1b82 (patch)
tree01834e207f42e59161b877426d64e08387171090 /marshal.c
parentc9423b016cfeab852bc5a829e55e0a11f80b3ab7 (diff)
downloadruby-0b1e26398e018116180bf41cb63887f77d5d1b82.tar.gz
Hoisted out w_ivar_each
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/marshal.c b/marshal.c
index a1ee01e2ca..c89ef962ee 100644
--- a/marshal.c
+++ b/marshal.c
@@ -665,13 +665,20 @@ has_ivars(VALUE obj, VALUE encname, VALUE *ivobj)
}
static void
+w_ivar_each(VALUE obj, st_index_t num, struct dump_call_arg *arg)
+{
+ struct w_ivar_arg ivarg = {arg, num};
+ if (!num) return;
+ rb_ivar_foreach(obj, w_obj_each, (st_data_t)&ivarg);
+}
+
+static void
w_ivar(st_index_t num, VALUE ivobj, VALUE encname, struct dump_call_arg *arg)
{
w_long(num, arg->arg);
w_encoding(encname, arg);
if (ivobj != Qundef) {
- struct w_ivar_arg ivarg = {arg, num};
- rb_ivar_foreach(ivobj, w_obj_each, (st_data_t)&ivarg);
+ w_ivar_each(ivobj, num, arg);
}
}
@@ -682,10 +689,7 @@ w_objivar(VALUE obj, struct dump_call_arg *arg)
rb_ivar_foreach(obj, obj_count_ivars, (st_data_t)&num);
w_long(num, arg->arg);
- if (num != 0) {
- struct w_ivar_arg ivarg = {arg, num};
- rb_ivar_foreach(obj, w_obj_each, (st_data_t)&ivarg);
- }
+ w_ivar_each(obj, num, arg);
}
static void