ruby
ruby copied to clipboard
Shink RClass when it is known they can't be namespaced
Even when namespaces are enabled, only a few core classes created during init will eventually be namespaced.
For these it's OK to allocate a 320B slot to hold the extra namespace stuff.
But for any class created post init, we know we'll never need the namespace and we can fit in a 160B slot.
But for any class created post init, we know we'll never need the namespace and we can fit in a 160B slot.
I wonder if this will be true in the future because of singleton classes of pre-init namespaceable classes (they either need to also be made namespaceable, or we'd need to use namespacing to look up klass 😩) https://bugs.ruby-lang.org/issues/21343
Good catch.
they either need to also be made namespaceable,
I think that is the way, but I can probably handle that. When creating a singleton class I can check if the attached object class is namespaceable.
I made it so that metaclasses created from a namespaceable class are also namespaceable. (I didn't fix https://bugs.ruby-lang.org/issues/21343 though.)