# File lib/ruby-prof/profile.rb, line 16 def detect_recursion(thread) visited_methods = Hash.new do |hash, key| hash[key] = 0 end visitor = CallInfoVisitor.new(thread) visitor.visit do |call_info, event| case event when :enter visited_methods[call_info.target] += 1 call_info.recursive = (visited_methods[call_info.target] > 1) when :exit visited_methods[call_info.target] -= 1 if visited_methods[call_info.target] == 0 visited_methods.delete(call_info.target) end end end end