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 ...@@ -4,6 +4,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
include GitlabRoutingHelper include GitlabRoutingHelper
include StorageHelper include StorageHelper
include TreeHelper include TreeHelper
include Gitlab::Utils::StrongMemoize
presents :project presents :project
...@@ -159,10 +160,12 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated ...@@ -159,10 +160,12 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
end end
def can_current_user_push_code? def can_current_user_push_code?
if empty_repo? strong_memoize(:can_current_user_push_code) do
can?(current_user, :push_code, project) if empty_repo?
else can?(current_user, :push_code, project)
user_can_push_to_branch?(current_user, default_branch) else
user_can_push_to_branch?(current_user, default_branch)
end
end end
end end
......
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