Skip to content

Commit 0cc41d3

Browse files
committed
proc.c: saves Binding#clone on copying ivars twice
1 parent 5ac435d commit 0cc41d3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

proc.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,8 @@ rb_binding_alloc(VALUE klass)
298298
return obj;
299299
}
300300

301-
302-
/* :nodoc: */
303301
static VALUE
304-
binding_dup(VALUE self)
302+
binding_copy(VALUE self)
305303
{
306304
VALUE bindval = rb_binding_alloc(rb_cBinding);
307305
rb_binding_t *src, *dst;
@@ -310,15 +308,21 @@ binding_dup(VALUE self)
310308
rb_vm_block_copy(bindval, &dst->block, &src->block);
311309
RB_OBJ_WRITE(bindval, &dst->pathobj, src->pathobj);
312310
dst->first_lineno = src->first_lineno;
313-
return rb_obj_dup_setup(self, bindval);
311+
return bindval;
312+
}
313+
314+
/* :nodoc: */
315+
static VALUE
316+
binding_dup(VALUE self)
317+
{
318+
return rb_obj_dup_setup(self, binding_copy(self));
314319
}
315320

316321
/* :nodoc: */
317322
static VALUE
318323
binding_clone(VALUE self)
319324
{
320-
VALUE bindval = binding_dup(self);
321-
return rb_obj_clone_setup(self, bindval, Qnil);
325+
return rb_obj_clone_setup(self, binding_copy(self), Qnil);
322326
}
323327

324328
VALUE

0 commit comments

Comments
 (0)