Skip to content

Commit 4ae5d4d

Browse files
committed
Merge pull request rails#11678 from vipulnsward/helper_destructive
Change from `map` => `map!` and `collect!` to save creation of extra array
2 parents ffb680e + 4ce11c0 commit 4ae5d4d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

actionview/lib/action_view/helpers/text_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def pluralize(count, singular, plural = nil)
215215
def word_wrap(text, options = {})
216216
line_width = options.fetch(:line_width, 80)
217217

218-
text.split("\n").collect do |line|
218+
text.split("\n").collect! do |line|
219219
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
220220
end * "\n"
221221
end
@@ -264,7 +264,7 @@ def simple_format(text, html_options = {}, options = {})
264264
if paragraphs.empty?
265265
content_tag(wrapper_tag, nil, html_options)
266266
else
267-
paragraphs.map { |paragraph|
267+
paragraphs.map! { |paragraph|
268268
content_tag(wrapper_tag, paragraph, html_options, options[:sanitize])
269269
}.join("\n\n").html_safe
270270
end

0 commit comments

Comments
 (0)