aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-06-24 21:49:49 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-06-24 21:49:49 -0700
commit6874caa4070f10cdbe104c9ac97dafd33dbdd282 (patch)
tree22281b78dc1e0bac0b3789844655f26f9e72f579 /activesupport
parent69e72af62261dd8971890711b51c6eef2c68bc71 (diff)
downloadrails-6874caa4070f10cdbe104c9ac97dafd33dbdd282.tar.gz
rails-6874caa4070f10cdbe104c9ac97dafd33dbdd282.tar.bz2
rails-6874caa4070f10cdbe104c9ac97dafd33dbdd282.zip
Performance: minor Array#to_param and #to_query speedups
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb
index a9882828ca..49ada8f174 100644
--- a/activesupport/lib/active_support/core_ext/array/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -27,7 +27,7 @@ module ActiveSupport #:nodoc:
# Calls <tt>to_param</tt> on all its elements and joins the result with
# slashes. This is used by <tt>url_for</tt> in Action Pack.
def to_param
- map(&:to_param).join '/'
+ collect { |e| e.to_param }.join '/'
end
# Converts an array into a string suitable for use as a URL query string,
@@ -35,7 +35,8 @@ module ActiveSupport #:nodoc:
#
# ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding"
def to_query(key)
- collect { |value| value.to_query("#{key}[]") } * '&'
+ prefix = "#{key}[]"
+ collect { |value| value.to_query(prefix) }.join '&'
end
def self.included(base) #:nodoc: