Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8576: introspection_optimization.patch

File introspection_optimization.patch, 0.9 kB (added by zenspider, 1 year ago)
  • introspection.rb

    old new  
    1919    parents 
    2020  end 
    2121   
     22  @@inherited_constants = {} 
    2223  # Return the constants that have been defined locally by this object and not 
    2324  # in an ancestor. This method may miss some constants if their definition in 
    2425  # the ancestor is identical to their definition in the receiver. 
    2526  def local_constants 
    26     inherited = {} 
    27     ancestors.each do |anc| 
    28       next if anc == self 
    29       anc.constants.each { |const| inherited[const] = anc.const_get(const) } 
    30     end 
    31     constants.select do |const| 
    32       ! inherited.key?(const) || inherited[const].object_id != const_get(const).object_id 
    33     end 
     27    @@inherited_constants[self] ||= constants - ancestors[1..-1].map { |k| k.constants }.flatten 
    3428  end 
    3529end