summaryrefslogtreecommitdiff
path: root/app/models/user_preference.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-07-24 11:11:18 -0700
committerStan Hu <stanhu@gmail.com>2019-07-24 11:47:58 -0700
commit3e001d29ccdb5a5b1ba223710525f8dc7ae844ee (patch)
tree5046754a8858795a02043a743e18fb8b05610f41 /app/models/user_preference.rb
parent0d538e44aff066372ecd9d10ac6786681bc347c9 (diff)
downloadgitlab-ce-3e001d29ccdb5a5b1ba223710525f8dc7ae844ee.tar.gz
Enable Rubocop Performance/InefficientHashSearchsh-enable-rubocop-hash-search
When used with a Hash, `.keys.include?` is bad because: 1. It performs a O(n) search instead of the efficient `.has_key?` 2. It clones all keys into separate array. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/64975
Diffstat (limited to 'app/models/user_preference.rb')
-rw-r--r--app/models/user_preference.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index f1326f4c8cb..b236250c24e 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -26,7 +26,7 @@ class UserPreference < ApplicationRecord
def set_notes_filter(filter_id, issuable)
# No need to update the column if the value is already set.
- if filter_id && NOTES_FILTERS.values.include?(filter_id)
+ if filter_id && NOTES_FILTERS.value?(filter_id)
field = notes_filter_field_for(issuable)
self[field] = filter_id