aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-02-08 15:48:59 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2016-02-08 15:48:59 -0800
commit783858c8e150eb0f98d7e5d893e492ee08998662 (patch)
tree5e1709c30b843ce447c9f458a128a3930ebc7036
parent02c3867882d6d23b10df262a6db5f937ca69fb53 (diff)
downloadrails-783858c8e150eb0f98d7e5d893e492ee08998662.tar.gz
rails-783858c8e150eb0f98d7e5d893e492ee08998662.tar.bz2
rails-783858c8e150eb0f98d7e5d893e492ee08998662.zip
drop array allocations on `html_safe`
For better or worse, anonymous `*` args will allocate arrays. Ideally, the interpreter would optimize away this allocation. However, given the number of times we call `html_safe` it seems worth the shedding idealism and going for performance. This line was the top allocation spot for a scaffold (and presumably worse on real applications).
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index 6251f34daf..43b9fd4bf7 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -171,7 +171,7 @@ module ActiveSupport #:nodoc:
original_concat(value)
end
- def initialize(*)
+ def initialize(str = '')
@html_safe = true
super
end