summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2018-08-02 21:54:21 +0000
committerGo MAEDA <maeda@farend.jp>2018-08-02 21:54:21 +0000
commiteee1c36b4b7f0cee23ebc5d3848fa2b606f603c8 (patch)
tree6618b8113ac99e4feb65ffbab90f87bc5da10349 /lib
parentc76a021e92e77036152935ac19af10893f56669f (diff)
downloadredmine-eee1c36b4b7f0cee23ebc5d3848fa2b606f603c8.tar.gz
redmine-eee1c36b4b7f0cee23ebc5d3848fa2b606f603c8.zip
Replace Enumerable#sort with faster Enumerable#sort_by (#29299).
Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@17462 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/helpers/gantt.rb2
-rw-r--r--lib/redmine/i18n.rb2
-rw-r--r--lib/redmine/scm/adapters/mercurial_adapter.rb2
-rw-r--r--lib/redmine/scm/adapters/subversion_adapter.rb2
-rw-r--r--lib/tasks/permissions.rake2
5 files changed, 5 insertions, 5 deletions
diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb
index ca3b70b6f..312a3133a 100644
--- a/lib/redmine/helpers/gantt.rb
+++ b/lib/redmine/helpers/gantt.rb
@@ -619,7 +619,7 @@ module Redmine
end
def self.sort_issues!(issues)
- issues.sort! {|a, b| sort_issue_logic(a) <=> sort_issue_logic(b)}
+ issues.sort_by! {|issue| sort_issue_logic(issue)}
end
def self.sort_issue_logic(issue)
diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb
index 43b74bb26..300fb8b06 100644
--- a/lib/redmine/i18n.rb
+++ b/lib/redmine/i18n.rb
@@ -120,7 +120,7 @@ module Redmine
valid_languages.
select {|locale| ::I18n.exists?(:general_lang_name, locale)}.
map {|lang| [ll(lang.to_s, :general_lang_name), lang.to_s]}.
- sort {|x,y| x.first <=> y.first }
+ sort_by(&:first)
else
ActionController::Base.cache_store.fetch "i18n/languages_options/#{Redmine::VERSION}" do
languages_options :cache => false
diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb
index 599c3a42f..a3b672d26 100644
--- a/lib/redmine/scm/adapters/mercurial_adapter.rb
+++ b/lib/redmine/scm/adapters/mercurial_adapter.rb
@@ -206,7 +206,7 @@ module Redmine
:path => with_leading_slash(p),
:from_path => (cpmap.member?(p) ? with_leading_slash(cpmap[p]) : nil),
:from_revision => (cpmap.member?(p) ? le['node'] : nil)}
- end.sort { |a, b| a[:path] <=> b[:path] }
+ end.sort_by { |e| e[:path] }
parents_ary = []
as_ary(le['parents']['parent']).map do |par|
parents_ary << par['__content__'] if par['__content__'] != "0000000000000000000000000000000000000000"
diff --git a/lib/redmine/scm/adapters/subversion_adapter.rb b/lib/redmine/scm/adapters/subversion_adapter.rb
index 318f045a0..11c8c9c60 100644
--- a/lib/redmine/scm/adapters/subversion_adapter.rb
+++ b/lib/redmine/scm/adapters/subversion_adapter.rb
@@ -168,7 +168,7 @@ module Redmine
:from_revision => path['copyfrom-rev']
}
end if logentry['paths'] && logentry['paths']['path']
- paths.sort! { |x,y| x[:path] <=> y[:path] }
+ paths.sort_by! {|e| e[:path]}
revisions << Revision.new({:identifier => logentry['revision'],
:author => (logentry['author'] ? logentry['author']['__content__'] : ""),
diff --git a/lib/tasks/permissions.rake b/lib/tasks/permissions.rake
index 02ce1b2a8..3ed53f1f1 100644
--- a/lib/tasks/permissions.rake
+++ b/lib/tasks/permissions.rake
@@ -2,7 +2,7 @@ namespace :redmine do
desc "List all permissions and the actions registered with them"
task :permissions => :environment do
puts "Permission Name - controller/action pairs"
- Redmine::AccessControl.permissions.sort {|a,b| a.name.to_s <=> b.name.to_s }.each do |permission|
+ Redmine::AccessControl.permissions.sort_by {|p| p.name.to_s}.each do |permission|
puts ":#{permission.name} - #{permission.actions.join(', ')}"
end
end