Skip to content
This repository
Browse code

Merge pull request #11678 from vipulnsward/helper_destructive

Change from `map` => `map!` and `collect!` to save creation of extra array
  • Loading branch information...
commit 4ae5d4d34e06c62cd693d0f8e3c7a5da51a9b26a 2 parents ffb680e + 4ce11c0
Rafael Mendonça França rafaelfranca authored

Showing 1 changed file with 2 additions and 2 deletions. Show diff stats Hide diff stats

  1. +2 2 actionview/lib/action_view/helpers/text_helper.rb
4 actionview/lib/action_view/helpers/text_helper.rb
@@ -215,7 +215,7 @@ def pluralize(count, singular, plural = nil)
215 215 def word_wrap(text, options = {})
216 216 line_width = options.fetch(:line_width, 80)
217 217
218   - text.split("\n").collect do |line|
  218 + text.split("\n").collect! do |line|
219 219 line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
220 220 end * "\n"
221 221 end
@@ -264,7 +264,7 @@ def simple_format(text, html_options = {}, options = {})
264 264 if paragraphs.empty?
265 265 content_tag(wrapper_tag, nil, html_options)
266 266 else
267   - paragraphs.map { |paragraph|
  267 + paragraphs.map! { |paragraph|
268 268 content_tag(wrapper_tag, paragraph, html_options, options[:sanitize])
269 269 }.join("\n\n").html_safe
270 270 end

0 comments on commit 4ae5d4d

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