From 365aa654d8bbe2889b75df2f5147bc25c54fa751 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 29 Aug 2014 18:19:30 -0700 Subject: reduce object allocations in utc_offset `try` allocates an array on every call, we should avoid calling it in hotspots. This reduced AttributeMethodsTest#test_setting_time_zone_aware_attribute_with_string from 18k allocations to 14k --- activesupport/lib/active_support/values/time_zone.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index ee62523824..49dfee96ec 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -276,8 +276,8 @@ module ActiveSupport if @utc_offset @utc_offset else - @current_period ||= tzinfo.try(:current_period) - @current_period.try(:utc_offset) + @current_period ||= tzinfo.current_period if tzinfo + @current_period.utc_offset if @current_period end end -- cgit v1.2.3