Skip to content
  • John Hawthorn's avatar
    80a0eca4
    Speed up arel visitor dispatch · 80a0eca4
    John Hawthorn authored
    This commit makes two performance tweaks to the dispatch_cache in
    Arel::Visitors::Visitor.
    
    First, it interns the method name into a symbol rather than a string.
    send expects a symbol, so this avoids Ruby needing to intern that string
    itself.
    
    Second, it changes the dispatch cache to an identity hash. Classes are
    already compared by identity, but Ruby is able to perform the lookup
    more quickly if it is explicit on the hash.
    80a0eca4
    Speed up arel visitor dispatch
    John Hawthorn authored
    This commit makes two performance tweaks to the dispatch_cache in
    Arel::Visitors::Visitor.
    
    First, it interns the method name into a symbol rather than a string.
    send expects a symbol, so this avoids Ruby needing to intern that string
    itself.
    
    Second, it changes the dispatch cache to an identity hash. Classes are
    already compared by identity, but Ruby is able to perform the lookup
    more quickly if it is explicit on the hash.
Loading