mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Reclaim one VALUE
from rb_classext_t
by shrinking super_classdepth
By making `super_classdepth` `uint16_t`, classes and modules can now fit in 160B slots again. The downside of course is that before `super_classdepth` was large enough we never had to care about overflow, as you couldn't realistically create enough classes to ever go over it. With this change, while it is stupid, you could realistically create an ancestor chain containing 65k classes and modules.
This commit is contained in:
parent
f855bcc6b2
commit
130d6aaef2
Notes:
git
2025-05-14 08:17:16 +00:00
2 changed files with 11 additions and 4 deletions
4
class.c
4
class.c
|
@ -827,7 +827,9 @@ rb_class_update_superclasses(VALUE klass)
|
|||
superclasses = class_superclasses_including_self(super);
|
||||
RCLASS_WRITE_SUPERCLASSES(super, super_depth, superclasses, true, true);
|
||||
}
|
||||
RCLASS_WRITE_SUPERCLASSES(klass, super_depth + 1, superclasses, false, false);
|
||||
|
||||
size_t depth = super_depth == RCLASS_MAX_SUPERCLASS_DEPTH ? super_depth : super_depth + 1;
|
||||
RCLASS_WRITE_SUPERCLASSES(klass, depth, superclasses, false, false);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue