提交 4ce11c01 编写于 作者: V Vipul A M

Change from `map` => `map!` and `collect!` to save creation of extra array.

上级 e14039ea
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册