diff --git a/lib/brakeman/processors/lib/find_all_calls.rb b/lib/brakeman/processors/lib/find_all_calls.rb index 86f3793962629e24128e6d0979c90de33ee96472..6f3896d33203441f5a3e6e7a573242caf6a6e2a4 100644 --- a/lib/brakeman/processors/lib/find_all_calls.rb +++ b/lib/brakeman/processors/lib/find_all_calls.rb @@ -9,6 +9,7 @@ class Brakeman::FindAllCalls < Brakeman::BaseProcessor @current_method = nil @in_target = false @calls = [] + @cache = {} end #Process the given source. Provide either class and method being searched @@ -145,11 +146,18 @@ class Brakeman::FindAllCalls < Brakeman::BaseProcessor def make_location if @current_template - { :type => :template, + key = [@current_template, @current_file] + cached = @cache[key] + return cached if cached + + @cache[key] = { :type => :template, :template => @current_template, :file => @current_file } else - { :type => :class, + key = [@current_class, @current_method, @current_file] + cached = @cache[key] + return cached if cached + @cache[key] = { :type => :class, :class => @current_class, :method => @current_method, :file => @current_file }