mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Simplify repeated member access macros
This commit is contained in:
parent
754adbee91
commit
b32987a3d7
1 changed files with 14 additions and 14 deletions
28
class.c
28
class.c
|
@ -89,14 +89,14 @@ rb_module_add_to_subclasses_list(VALUE module, VALUE iclass)
|
||||||
void
|
void
|
||||||
rb_class_remove_from_super_subclasses(VALUE klass)
|
rb_class_remove_from_super_subclasses(VALUE klass)
|
||||||
{
|
{
|
||||||
rb_subclass_entry_t *entry;
|
rb_subclass_entry_t **prev = RCLASS_PARENT_SUBCLASSES(klass);
|
||||||
|
|
||||||
if (RCLASS_PARENT_SUBCLASSES(klass)) {
|
if (prev) {
|
||||||
entry = *RCLASS_PARENT_SUBCLASSES(klass);
|
rb_subclass_entry_t *entry = *prev, *next = entry->next;
|
||||||
|
|
||||||
*RCLASS_PARENT_SUBCLASSES(klass) = entry->next;
|
*prev = next;
|
||||||
if (entry->next) {
|
if (next) {
|
||||||
RCLASS_PARENT_SUBCLASSES(entry->next->klass) = RCLASS_PARENT_SUBCLASSES(klass);
|
RCLASS_PARENT_SUBCLASSES(next->klass) = prev;
|
||||||
}
|
}
|
||||||
xfree(entry);
|
xfree(entry);
|
||||||
}
|
}
|
||||||
|
@ -107,14 +107,14 @@ rb_class_remove_from_super_subclasses(VALUE klass)
|
||||||
void
|
void
|
||||||
rb_class_remove_from_module_subclasses(VALUE klass)
|
rb_class_remove_from_module_subclasses(VALUE klass)
|
||||||
{
|
{
|
||||||
rb_subclass_entry_t *entry;
|
rb_subclass_entry_t **prev = RCLASS_MODULE_SUBCLASSES(klass);
|
||||||
|
|
||||||
if (RCLASS_MODULE_SUBCLASSES(klass)) {
|
if (prev) {
|
||||||
entry = *RCLASS_MODULE_SUBCLASSES(klass);
|
rb_subclass_entry_t *entry = *prev, *next = entry->next;
|
||||||
*RCLASS_MODULE_SUBCLASSES(klass) = entry->next;
|
|
||||||
|
|
||||||
if (entry->next) {
|
*prev = next;
|
||||||
RCLASS_MODULE_SUBCLASSES(entry->next->klass) = RCLASS_MODULE_SUBCLASSES(klass);
|
if (next) {
|
||||||
|
RCLASS_MODULE_SUBCLASSES(next->klass) = prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(entry);
|
xfree(entry);
|
||||||
|
@ -1124,10 +1124,10 @@ do_include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super
|
||||||
add_subclass = FALSE;
|
add_subclass = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if (add_subclass) {
|
||||||
VALUE m = module;
|
VALUE m = module;
|
||||||
if (BUILTIN_TYPE(m) == T_ICLASS) m = RBASIC(m)->klass;
|
if (BUILTIN_TYPE(m) == T_ICLASS) m = RBASIC(m)->klass;
|
||||||
if (add_subclass) rb_module_add_to_subclasses_list(m, iclass);
|
rb_module_add_to_subclasses_list(m, iclass);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FL_TEST(klass, RMODULE_IS_REFINEMENT)) {
|
if (FL_TEST(klass, RMODULE_IS_REFINEMENT)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue