From 7bba6adc56b20606101131069ef8f1f96ff71fa2 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 25 Jun 2015 08:37:27 +0000 Subject: * vm_method.c (rb_method_entry_create): need to call method_definition_reset() if def is given. Actually, `me' is a new object, so we don't need to call it. It is just to make sure. * vm_method.c (method_definition_reset): remove duplicated insertion. * vm_method.c (rb_method_entry_clone): assgine dst->def here, not in method_definition_reset(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_method.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'vm_method.c') diff --git a/vm_method.c b/vm_method.c index 5a40e370d8..43b5d2aafc 100644 --- a/vm_method.c +++ b/vm_method.c @@ -283,9 +283,9 @@ method_definition_set(rb_method_entry_t *me, rb_method_definition_t *def, void * } static void -method_definition_reset(const rb_method_entry_t *me, rb_method_definition_t *def) +method_definition_reset(const rb_method_entry_t *me) { - *(rb_method_definition_t **)&me->def = def; + rb_method_definition_t *def = me->def; switch(def->type) { case VM_METHOD_TYPE_ISEQ: @@ -338,6 +338,7 @@ rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, c { rb_method_entry_t *me = (rb_method_entry_t *)rb_imemo_new(imemo_ment, (VALUE)def, (VALUE)called_id, (VALUE)klass, 0); METHOD_ENTRY_FLAGS_SET(me, visi, ruby_running ? FALSE : TRUE, rb_safe_level()); + if (def != NULL) method_definition_reset(me); return me; } @@ -353,7 +354,8 @@ rb_method_entry_clone(const rb_method_entry_t *src_me) void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src) { - method_definition_reset(dst, method_definition_addref(src->def)); + *(rb_method_definition_t **)&dst->def = method_definition_addref(src->def); + method_definition_reset(dst); dst->called_id = src->called_id; RB_OBJ_WRITE((VALUE)dst, &dst->klass, src->klass); } -- cgit v1.2.3