mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Inherit max_iv_count from superclass
In 274870bd54
we gained the ability to
make an educated guess at the max_iv_count of a class based on its
initialize method. This commit makes subclasses inherit their super's
max_iv_count, which makes the estimate work in cases that the subclass
does not have an initialize method.
This commit is contained in:
parent
171e94bd95
commit
da204d2eee
Notes:
git
2022-12-01 23:37:35 +00:00
1 changed files with 7 additions and 1 deletions
8
class.c
8
class.c
|
@ -326,7 +326,13 @@ rb_class_new(VALUE super)
|
|||
{
|
||||
Check_Type(super, T_CLASS);
|
||||
rb_check_inheritable(super);
|
||||
return rb_class_boot(super);
|
||||
VALUE klass = rb_class_boot(super);
|
||||
|
||||
if (super != rb_cObject && super != rb_cBasicObject) {
|
||||
RCLASS_EXT(klass)->max_iv_count = RCLASS_EXT(super)->max_iv_count;
|
||||
}
|
||||
|
||||
return klass;
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue