aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2018-04-18 12:21:05 -0500
committerGitHub <noreply@github.com>2018-04-18 12:21:05 -0500
commit7bcb04c73decc9fa0448cf75caeee6740942ad29 (patch)
tree336fb66f9866e011c969c7ef51d990a468dbe135 /actionview
parent0ac549a49a690416865793e48bd7c3d3afe91a94 (diff)
parent385260590f9851b9f48c678b3d4313fce712c244 (diff)
downloadrails-7bcb04c73decc9fa0448cf75caeee6740942ad29.tar.gz
rails-7bcb04c73decc9fa0448cf75caeee6740942ad29.tar.bz2
rails-7bcb04c73decc9fa0448cf75caeee6740942ad29.zip
Merge pull request #32326 from q-centrix/perf-improvement-translation-helper-default-array
Only create an array with default options if we have default options
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/helpers/translation_helper.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb
index 80cb73d683..db44fdbfee 100644
--- a/actionview/lib/action_view/helpers/translation_helper.rb
+++ b/actionview/lib/action_view/helpers/translation_helper.rb
@@ -60,7 +60,11 @@ module ActionView
def translate(key, options = {})
options = options.dup
has_default = options.has_key?(:default)
- remaining_defaults = Array(options.delete(:default)).compact
+ if has_default
+ remaining_defaults = Array(options.delete(:default)).compact
+ else
+ remaining_defaults = []
+ end
if has_default && !remaining_defaults.first.kind_of?(Symbol)
options[:default] = remaining_defaults