From 783858c8e150eb0f98d7e5d893e492ee08998662 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 8 Feb 2016 15:48:59 -0800 Subject: [PATCH] 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). --- .../lib/active_support/core_ext/string/output_safety.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ def safe_concat(value) original_concat(value) end - def initialize(*) + def initialize(str = '') @html_safe = true super end -- GitLab