]> source.dussan.org Git - redmine.git/commitdiff
Replace Hash#keys.each with faster Hash#each_key (#29305).
authorGo MAEDA <maeda@farend.jp>
Wed, 1 Aug 2018 14:28:39 +0000 (14:28 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 1 Aug 2018 14:28:39 +0000 (14:28 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@17458 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_query.rb
app/models/query.rb
app/models/user_preference.rb
lib/plugins/open_id_authentication/lib/open_id_authentication.rb
lib/redmine/helpers/gantt.rb

index ad5e511af0397a4649c7951a708c4f0210ad4ad5..c342dc4561e467f00738b5148c329f6af6c1f134 100644 (file)
@@ -582,7 +582,7 @@ class IssueQuery < Query
   end
   alias :find_author_id_filter_values :find_assigned_to_id_filter_values
 
-  IssueRelation::TYPES.keys.each do |relation_type|
+  IssueRelation::TYPES.each_key do |relation_type|
     alias_method "sql_for_#{relation_type}_field".to_sym, :sql_for_relations
   end
 
index f85fd0f65082ecf6f15f2f0c87af7650abdfb4a0..ed11bbffb8f6e4ccc4551be7f1a55da044f0ffae 100644 (file)
@@ -371,7 +371,7 @@ class Query < ActiveRecord::Base
       self.filters = {}
       add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v])
     else
-      available_filters.keys.each do |field|
+      available_filters.each_key do |field|
         add_short_filter(field, params[field]) if params[field]
       end
     end
@@ -989,7 +989,7 @@ class Query < ActiveRecord::Base
 
   def map_total(total, &block)
     if total.is_a?(Hash)
-      total.keys.each {|k| total[k] = yield total[k]}
+      total.each_key {|k| total[k] = yield total[k]}
     else
       total = yield total
     end
index efdc41e2dfaf4189febf1b8b2a7126f6a203c3d3..7373290c5aef95b0972d5fb20a69d230ec7df5aa 100644 (file)
@@ -122,7 +122,7 @@ class UserPreference < ActiveRecord::Base
   #   preferences.remove_block('news')
   def remove_block(block)
     block = block.to_s.underscore
-    my_page_layout.keys.each do |group|
+    my_page_layout.each_key do |group|
       my_page_layout[group].delete(block)
     end
     my_page_layout
index 7afe6fdebf7864b7b4dac9751158646ff5b1e4d8..e31aba1f2412248b10ad0519f00398d9aec87506 100644 (file)
@@ -61,7 +61,7 @@ module OpenIdAuthentication
       @code
     end
 
-    ERROR_MESSAGES.keys.each { |state| define_method("#{state}?") { @code == state } }
+    ERROR_MESSAGES.each_key { |state| define_method("#{state}?") { @code == state } }
 
     def successful?
       @code == :successful
index 756dc6e93f3232374c1ab7395b29cdec76a2a367..ca3b70b6f5a4e50369b365b3bda8cc8f741618f1 100644 (file)
@@ -608,7 +608,7 @@ module Redmine
           end
         end
         # Transforms dates into pixels witdh
-        coords.keys.each do |key|
+        coords.each_key do |key|
           coords[key] = (coords[key] * zoom).floor
         end
         coords