Skip to content
Browse files

Merge pull request #11678 from vipulnsward/helper_destructive

Change from `map` => `map!` and `collect!` to save creation of extra array
  • Loading branch information...
2 parents ffb680e + 4ce11c0 commit 4ae5d4d34e06c62cd693d0f8e3c7a5da51a9b26a @rafaelfranca rafaelfranca committed Jul 31, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 actionview/lib/action_view/helpers/text_helper.rb
View
4 actionview/lib/action_view/helpers/text_helper.rb
@@ -215,7 +215,7 @@ def pluralize(count, singular, plural = nil)
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 @@ def simple_format(text, html_options = {}, options = {})
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

0 comments on commit 4ae5d4d

Please sign in to comment.
Something went wrong with that request. Please try again.