aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-07-31 05:38:51 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-07-31 05:38:51 -0700
commit4ae5d4d34e06c62cd693d0f8e3c7a5da51a9b26a (patch)
treede36bedc83f7b38a32d76de1c1ae932940ffb7cd /actionview/lib/action_view/helpers
parentffb680e121b1868c184381882b083290db230d78 (diff)
parent4ce11c0150bc7c56931cd24ce5a9792e6605795b (diff)
downloadrails-4ae5d4d34e06c62cd693d0f8e3c7a5da51a9b26a.tar.gz
rails-4ae5d4d34e06c62cd693d0f8e3c7a5da51a9b26a.tar.bz2
rails-4ae5d4d34e06c62cd693d0f8e3c7a5da51a9b26a.zip
Merge pull request #11678 from vipulnsward/helper_destructive
Change from `map` => `map!` and `collect!` to save creation of extra array
Diffstat (limited to 'actionview/lib/action_view/helpers')
-rw-r--r--actionview/lib/action_view/helpers/text_helper.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/actionview/lib/action_view/helpers/text_helper.rb b/actionview/lib/action_view/helpers/text_helper.rb
index 6fe250d3c1..e3d4eb1d74 100644
--- a/actionview/lib/action_view/helpers/text_helper.rb
+++ b/actionview/lib/action_view/helpers/text_helper.rb
@@ -215,7 +215,7 @@ module ActionView
def word_wrap(text, options = {})
line_width = options.fetch(:line_width, 80)
- text.split("\n").collect do |line|
+ text.split("\n").collect! do |line|
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
end * "\n"
end
@@ -264,7 +264,7 @@ module ActionView
if paragraphs.empty?
content_tag(wrapper_tag, nil, html_options)
else
- paragraphs.map { |paragraph|
+ paragraphs.map! { |paragraph|
content_tag(wrapper_tag, paragraph, html_options, options[:sanitize])
}.join("\n\n").html_safe
end