diff options
author | thedarkone <thedarkone2@gmail.com> | 2013-08-07 17:15:58 +0200 |
---|---|---|
committer | thedarkone <thedarkone2@gmail.com> | 2013-08-07 17:15:58 +0200 |
commit | c4e5db4d451e1537ab96405193150e3785f3ecf9 (patch) | |
tree | 7bcbffa55c411d4767a33cd544939083949465f6 /activesupport | |
parent | 548910a67a194d5daf588e3d9a8441a941809a7c (diff) | |
download | rails-c4e5db4d451e1537ab96405193150e3785f3ecf9.tar.gz rails-c4e5db4d451e1537ab96405193150e3785f3ecf9.tar.bz2 rails-c4e5db4d451e1537ab96405193150e3785f3ecf9.zip |
Unify AS::TZ's lazy init maps.
There's no point in having 2 almost identical (@lazy_zones_map and @zones_map) lazy initialized TZ instance caches.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/values/time_zone.rb | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 2c78fe3ee8..b8e6b06087 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -185,6 +185,8 @@ module ActiveSupport UTC_OFFSET_WITH_COLON = '%s%02d:%02d' UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.sub(':', '') + @lazy_zones_map = ThreadSafe::Cache.new + # Assumes self represents an offset from UTC in seconds (as returned from # Time#utc_offset) and turns this into an +HH:MM formatted string. # @@ -363,11 +365,8 @@ module ActiveSupport def zones_map @zones_map ||= begin - map = {} - MAPPING.each_key do |place| - map[place] = lazy_zones_map.fetch(place) { create(place) } - end - map + MAPPING.each_key {|place| self[place]} # load all the zones + @lazy_zones_map end end @@ -415,10 +414,7 @@ module ActiveSupport def lazy_zones_map require_tzinfo - - @lazy_zones_map ||= ThreadSafe::Cache.new do |hash, place| - hash[place] = create(place) if MAPPING.has_key?(place) - end + @lazy_zones_map end end |