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,12 +160,14 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated ...@@ -159,12 +160,14 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
end end
def can_current_user_push_code? def can_current_user_push_code?
strong_memoize(:can_current_user_push_code) do
if empty_repo? if empty_repo?
can?(current_user, :push_code, project) can?(current_user, :push_code, project)
else else
user_can_push_to_branch?(current_user, default_branch) user_can_push_to_branch?(current_user, default_branch)
end end
end end
end
def files_anchor_data def files_anchor_data
OpenStruct.new(enabled: true, 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