summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-12-24 16:28:03 +0100
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-12-24 16:28:03 +0100
commit7caaa10807ce61bc1489c91c9150c92ca7997132 (patch)
treeeb74b359d38d0a7eabb728870234acc610b9ca6c
parent1a23af485cd755738f4051e04132b1eb93fc3fab (diff)
parent03a40a7ee1262d5b68e5f7aba26077dc3bef6b33 (diff)
downloadgitlab-ce-7caaa10807ce61bc1489c91c9150c92ca7997132.tar.gz
Merge pull request #9915 from huacnlee/avoid-ability-methods-allocations
Avoid allocations in Ability class.
-rw-r--r--app/models/ability.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb
index cd5ae0fb0fd..1b3ee757040 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -132,14 +132,14 @@ class Ability
end
def public_project_rules
- project_guest_rules + [
+ @public_project_rules ||= project_guest_rules + [
:download_code,
:fork_project
]
end
def project_guest_rules
- [
+ @project_guest_rules ||= [
:read_project,
:read_wiki,
:read_issue,
@@ -157,7 +157,7 @@ class Ability
end
def project_report_rules
- project_guest_rules + [
+ @project_report_rules ||= project_guest_rules + [
:create_commit_status,
:read_commit_statuses,
:download_code,
@@ -170,7 +170,7 @@ class Ability
end
def project_dev_rules
- project_report_rules + [
+ @project_dev_rules ||= project_report_rules + [
:admin_merge_request,
:create_merge_request,
:create_wiki,
@@ -181,7 +181,7 @@ class Ability
end
def project_archived_rules
- [
+ @project_archived_rules ||= [
:create_merge_request,
:push_code,
:push_code_to_protected_branches,
@@ -191,7 +191,7 @@ class Ability
end
def project_master_rules
- project_dev_rules + [
+ @project_master_rules ||= project_dev_rules + [
:push_code_to_protected_branches,
:update_project_snippet,
:update_merge_request,
@@ -206,7 +206,7 @@ class Ability
end
def project_admin_rules
- project_master_rules + [
+ @project_admin_rules ||= project_master_rules + [
:change_namespace,
:change_visibility_level,
:rename_project,
@@ -332,7 +332,7 @@ class Ability
end
if snippet.public? || snippet.internal?
- rules << :read_personal_snippet
+ rules << :read_personal_snippet
end
rules