Ticket #8576: introspection_optimization.patch
| File introspection_optimization.patch, 0.9 kB (added by zenspider, 1 year ago) |
|---|
-
introspection.rb
old new 19 19 parents 20 20 end 21 21 22 @@inherited_constants = {} 22 23 # Return the constants that have been defined locally by this object and not 23 24 # in an ancestor. This method may miss some constants if their definition in 24 25 # the ancestor is identical to their definition in the receiver. 25 26 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 34 28 end 35 29 end