Commit 70156f3b authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Memoize method which is called multiple times on presenter

parent 1521fd9f
......@@ -4,6 +4,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
include GitlabRoutingHelper
include StorageHelper
include TreeHelper
include Gitlab::Utils::StrongMemoize
presents :project
......@@ -159,12 +160,14 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
end
def can_current_user_push_code?
strong_memoize(:can_current_user_push_code) do
if empty_repo?
can?(current_user, :push_code, project)
else
user_can_push_to_branch?(current_user, default_branch)
end
end
end
def files_anchor_data
OpenStruct.new(enabled: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment