Skip to content
  • Jemma Issroff's avatar
    a3d552ae
    Add variation_count on classes · a3d552ae
    Jemma Issroff authored
    
    
    Count how many "variations" each class creates. A "variation" is a a
    unique ordering of instance variables on a particular class. This can
    also be thought of as a branch in the shape tree.
    
    For example, the following Foo class will have 2 variations:
    
    ```ruby
    class Foo ; end
    
    Foo.new.instance_variable_set(:@a, 1) # case 1: creates one variation
    Foo.new.instance_variable_set(:@b, 1) # case 2: creates another variation
    
    foo = Foo.new
    foo.instance_variable_set(:@a, 1) # does not create a new variation
    foo.instance_variable_set(:@b, 1) # does not create a new variation (a continuation of the variation in case 1)
    ```
    
    We will use this number to limit the amount of shapes that a class can
    create and fallback to using a hash iv lookup.
    
    Co-Authored-By: default avatarAaron Patterson <tenderlove@ruby-lang.org>
    a3d552ae
    Add variation_count on classes
    Jemma Issroff authored
    
    
    Count how many "variations" each class creates. A "variation" is a a
    unique ordering of instance variables on a particular class. This can
    also be thought of as a branch in the shape tree.
    
    For example, the following Foo class will have 2 variations:
    
    ```ruby
    class Foo ; end
    
    Foo.new.instance_variable_set(:@a, 1) # case 1: creates one variation
    Foo.new.instance_variable_set(:@b, 1) # case 2: creates another variation
    
    foo = Foo.new
    foo.instance_variable_set(:@a, 1) # does not create a new variation
    foo.instance_variable_set(:@b, 1) # does not create a new variation (a continuation of the variation in case 1)
    ```
    
    We will use this number to limit the amount of shapes that a class can
    create and fallback to using a hash iv lookup.
    
    Co-Authored-By: default avatarAaron Patterson <tenderlove@ruby-lang.org>
Loading