This commit is contained in:
Yusuke Endoh 2021-11-05 21:31:31 +09:00
Родитель 64007fc57f
Коммит 3628616dd1
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -1349,7 +1349,7 @@ class_descendants_recursive(VALUE klass, VALUE v)
struct subclass_traverse_data *data = (struct subclass_traverse_data *) v; struct subclass_traverse_data *data = (struct subclass_traverse_data *) v;
if (BUILTIN_TYPE(klass) == T_CLASS && !FL_TEST(klass, FL_SINGLETON)) { if (BUILTIN_TYPE(klass) == T_CLASS && !FL_TEST(klass, FL_SINGLETON)) {
if (data->buffer && (data->count < data->maxcount || data->maxcount == -1)) { if (data->buffer && data->count < data->maxcount) {
data->buffer[data->count] = klass; data->buffer[data->count] = klass;
} }
data->count++; data->count++;
@ -1383,7 +1383,7 @@ rb_class_descendants(VALUE klass)
// estimate the count of subclasses // estimate the count of subclasses
rb_class_foreach_subclass(klass, class_descendants_recursive, (VALUE) &data); rb_class_foreach_subclass(klass, class_descendants_recursive, (VALUE) &data);
// this allocation may cause GC which may reduce the subclasses // the following allocation may cause GC which may change the number of subclasses
data.buffer = ALLOC_N(VALUE, data.count); data.buffer = ALLOC_N(VALUE, data.count);
data.maxcount = data.count; data.maxcount = data.count;
data.count = 0; data.count = 0;