Replace Hash#keys.each with faster Hash#each_key (#29305).

Patch by Go MAEDA.


git-svn-id: http://svn.redmine.org/redmine/trunk@17458 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2018-08-01 14:28:39 +00:00
parent 1e0663de9d
commit ed14823d13
5 changed files with 6 additions and 6 deletions

View File

@@ -582,7 +582,7 @@ class IssueQuery < Query
end end
alias :find_author_id_filter_values :find_assigned_to_id_filter_values 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 alias_method "sql_for_#{relation_type}_field".to_sym, :sql_for_relations
end end

View File

@@ -371,7 +371,7 @@ class Query < ActiveRecord::Base
self.filters = {} self.filters = {}
add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v]) add_filters(params[:fields] || params[:f], params[:operators] || params[:op], params[:values] || params[:v])
else else
available_filters.keys.each do |field| available_filters.each_key do |field|
add_short_filter(field, params[field]) if params[field] add_short_filter(field, params[field]) if params[field]
end end
end end
@@ -989,7 +989,7 @@ class Query < ActiveRecord::Base
def map_total(total, &block) def map_total(total, &block)
if total.is_a?(Hash) if total.is_a?(Hash)
total.keys.each {|k| total[k] = yield total[k]} total.each_key {|k| total[k] = yield total[k]}
else else
total = yield total total = yield total
end end

View File

@@ -122,7 +122,7 @@ class UserPreference < ActiveRecord::Base
# preferences.remove_block('news') # preferences.remove_block('news')
def remove_block(block) def remove_block(block)
block = block.to_s.underscore 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) my_page_layout[group].delete(block)
end end
my_page_layout my_page_layout

View File

@@ -61,7 +61,7 @@ module OpenIdAuthentication
@code @code
end end
ERROR_MESSAGES.keys.each { |state| define_method("#{state}?") { @code == state } } ERROR_MESSAGES.each_key { |state| define_method("#{state}?") { @code == state } }
def successful? def successful?
@code == :successful @code == :successful

View File

@@ -608,7 +608,7 @@ module Redmine
end end
end end
# Transforms dates into pixels witdh # Transforms dates into pixels witdh
coords.keys.each do |key| coords.each_key do |key|
coords[key] = (coords[key] * zoom).floor coords[key] = (coords[key] * zoom).floor
end end
coords coords