diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-29 18:19:30 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-29 18:19:30 -0700 |
commit | 365aa654d8bbe2889b75df2f5147bc25c54fa751 (patch) | |
tree | 15bd7a6b56ccef99b47f4cf35ea758300ab5c0f6 /activesupport | |
parent | 5e51bdda59c9ba8e5faf86294e3e431bd45f1830 (diff) | |
download | rails-365aa654d8bbe2889b75df2f5147bc25c54fa751.tar.gz rails-365aa654d8bbe2889b75df2f5147bc25c54fa751.tar.bz2 rails-365aa654d8bbe2889b75df2f5147bc25c54fa751.zip |
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
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/values/time_zone.rb | 4 |
1 files changed, 2 insertions, 2 deletions
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 |