From 20b4794ff7a77216fade68af8b1a0b54164b0c38 Mon Sep 17 00:00:00 2001 From: Max Melentiev Date: Sat, 28 Apr 2018 10:42:19 +0300 Subject: Don't allocate unnecessary array in translation helper --- actionview/lib/action_view/helpers/translation_helper.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'actionview') 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. -- cgit v1.2.3