diff options
author | George Claghorn <george.claghorn@gmail.com> | 2018-04-29 00:58:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-29 00:58:20 -0400 |
commit | d1b84c35a5d947025283a67dd182fcb8f2a05d09 (patch) | |
tree | 3601af08f0b0309fa93503dd873af697ac903584 /actionview/lib/action_view | |
parent | 3e8c660c11df5f650109fb44d060ea7eb0c7ea26 (diff) | |
parent | 20b4794ff7a77216fade68af8b1a0b54164b0c38 (diff) | |
download | rails-d1b84c35a5d947025283a67dd182fcb8f2a05d09.tar.gz rails-d1b84c35a5d947025283a67dd182fcb8f2a05d09.tar.bz2 rails-d1b84c35a5d947025283a67dd182fcb8f2a05d09.zip |
Merge pull request #32747 from printercu/improve_t_helper
Don't allocate unnecessary array in translation helper
Diffstat (limited to 'actionview/lib/action_view')
-rw-r--r-- | actionview/lib/action_view/helpers/translation_helper.rb | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb index db44fdbfee..d3cdab0d2f 100644 --- a/actionview/lib/action_view/helpers/translation_helper.rb +++ b/actionview/lib/action_view/helpers/translation_helper.rb @@ -59,15 +59,9 @@ module ActionView # they can provide HTML values for. def translate(key, options = {}) options = options.dup - has_default = options.has_key?(:default) - if has_default + if options.has_key?(: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 + options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol) end # If the user has explicitly decided to NOT raise errors, pass that option to I18n. |