diff options
author | Vipul A M <vipulnsward@gmail.com> | 2013-07-31 01:21:16 +0530 |
---|---|---|
committer | Vipul A M <vipulnsward@gmail.com> | 2013-07-31 10:07:04 +0530 |
commit | 4ce11c0150bc7c56931cd24ce5a9792e6605795b (patch) | |
tree | b83d757ddf8021cfd0e12453bdb0c1f171f5326e | |
parent | e14039eacb7448399a5942751ef38f3a051b5ea4 (diff) | |
download | rails-4ce11c0150bc7c56931cd24ce5a9792e6605795b.tar.gz rails-4ce11c0150bc7c56931cd24ce5a9792e6605795b.tar.bz2 rails-4ce11c0150bc7c56931cd24ce5a9792e6605795b.zip |
Change from `map` => `map!` and `collect!` to save creation of extra array.
-rw-r--r-- | actionview/lib/action_view/helpers/text_helper.rb | 4 |
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 |