diff options
author | Stan Hu <stanhu@gmail.com> | 2019-07-24 11:11:18 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-07-24 11:47:58 -0700 |
commit | 3e001d29ccdb5a5b1ba223710525f8dc7ae844ee (patch) | |
tree | 5046754a8858795a02043a743e18fb8b05610f41 /app/models/user_preference.rb | |
parent | 0d538e44aff066372ecd9d10ac6786681bc347c9 (diff) | |
download | gitlab-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.rb | 2 |
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 |