Skip to content
  • John Hawthorn's avatar
    19f331f5
    Dedup superclass array in leaf sibling classes · 19f331f5
    John Hawthorn authored
    Previously, we would build a new `superclasses` array for each class,
    even though for all immediate subclasses of a class, the array is
    identical.
    
    This avoids duplicating the arrays on leaf classes (those without
    subclasses) by calculating and storing a "superclasses including self"
    array on a class when it's first inherited and sharing that among all
    superclasses.
    
    An additional trick used is that the "superclass array including self"
    is valid as "self"'s superclass array. It just has it's own class at the
    end. We can use this to avoid an extra pointer of storage and can use
    one bit of a flag to track that we've "upgraded" the array.
    19f331f5
    Dedup superclass array in leaf sibling classes
    John Hawthorn authored
    Previously, we would build a new `superclasses` array for each class,
    even though for all immediate subclasses of a class, the array is
    identical.
    
    This avoids duplicating the arrays on leaf classes (those without
    subclasses) by calculating and storing a "superclasses including self"
    array on a class when it's first inherited and sharing that among all
    superclasses.
    
    An additional trick used is that the "superclass array including self"
    is valid as "self"'s superclass array. It just has it's own class at the
    end. We can use this to avoid an extra pointer of storage and can use
    one bit of a flag to track that we've "upgraded" the array.
Loading