summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-09-25 17:00:25 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-09-30 10:26:38 +0900
commit6c6a25feca8752205d81c5247f85d8ae8fb880d8 (patch)
tree449e41fc35b50b0d498f646303c49935d05b457b /class.c
parent167e6b48f1b321d671998728adf5a0db06d24445 (diff)
refactor add rb_method_entry_from_template
Tired of rb_method_entry_create(..., rb_method_definition_create( ..., &(rb_method_foo_t) {...})) maneuver. Provide a function that does the thing to reduce copy&paste.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2486
Diffstat (limited to 'class.c')
-rw-r--r--class.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/class.c b/class.c
index 308033d..3160444 100644
--- a/class.c
+++ b/class.c
@@ -967,18 +967,11 @@ inject_refined_method(ID *key, VALUE *value, void *data, int _)
const tuple *ptr = data;
const rb_method_entry_t *me = *(rb_method_entry_t **) value;
const rb_method_entry_t *orig_me = me->def->body.refined.orig_me;
- rb_method_entry_t *new_me =
- rb_method_entry_create(
- me->called_id,
- me->owner,
- me->defined_class,
- rb_method_definition_create(
- me->def->type,
- me->def->original_id,
- &(rb_method_refined_t) {
- .orig_me = NULL,
- .owner = me->def->body.refined.owner, }));
- METHOD_ENTRY_FLAGS_COPY(new_me, me);
+ const rb_method_entry_t *new_me =
+ rb_method_entry_from_template(
+ me, &(rb_method_refined_t) {
+ .orig_me = NULL,
+ .owner = me->def->body.refined.owner, });
rb_id_table_insert(RCLASS_M_TBL(ptr->klass), *key, (VALUE)new_me);
RB_OBJ_WRITTEN(ptr->klass, Qundef, new_me);
*value = (VALUE)rb_method_entry_clone(orig_me);