ruby-changes:46011
From: nobu <ko1@a...>
Date: Sat, 25 Mar 2017 11:57:35 +0900 (JST)
Subject: [ruby-changes:46011] nobu:r58082 (trunk): class.c: ensure_includable
nobu 2017-03-25 11:57:30 +0900 (Sat, 25 Mar 2017) New Revision: 58082 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58082 Log: class.c: ensure_includable * class.c (ensure_includable): extract checks to include and prepend. Modified files: trunk/class.c Index: class.c =================================================================== --- class.c (revision 58081) +++ class.c (revision 58082) @@ -849,14 +849,20 @@ rb_include_class_new(VALUE module, VALUE https://github.com/ruby/ruby/blob/trunk/class.c#L849 static int include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super); +static void +ensure_includable(VALUE klass, VALUE module) +{ + rb_frozen_class_p(klass); + Check_Type(module, T_MODULE); + OBJ_INFECT(klass, module); +} + void rb_include_module(VALUE klass, VALUE module) { int changed = 0; - rb_frozen_class_p(klass); - Check_Type(module, T_MODULE); - OBJ_INFECT(klass, module); + ensure_includable(klass, module); changed = include_modules_at(klass, RCLASS_ORIGIN(klass), module, TRUE); if (changed < 0) @@ -966,9 +972,7 @@ rb_prepend_module(VALUE klass, VALUE mod https://github.com/ruby/ruby/blob/trunk/class.c#L972 VALUE origin; int changed = 0; - rb_frozen_class_p(klass); - Check_Type(module, T_MODULE); - OBJ_INFECT(klass, module); + ensure_includable(klass, module); origin = RCLASS_ORIGIN(klass); if (origin == klass) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/