Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Make sure require_tzinfo only calls Kernel#require if TZInfo isn't al…

…ready present.

This wasn't a problem when require_tzinfo was only called from TimeZone#initialize, but now it's being called for every lookup to TimeZone.[] (via lazy_zones_map)

TimeZone lookup can occur when unmarshalling TimeWithZone objects, which is where I first saw the big slowdown (500ms for each Rails action that loaded from Rails.cache)
  • Loading branch information...
commit d6d474032a27c6ea86e97e7011b1e66de4b7c652 1 parent df21e3d
@toolmantim toolmantim authored
2  activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*Rails 3.1.1 (unreleased)*
+* Fixed performance issue where TimeZone lookups would require tzinfo each time [Tim Lucas]
* ActiveSupport::OrderedHash is now marked as extractable when using Array#extract_options! [Prem Sichanugrist]
*Rails 3.1.0 (August 30, 2011)*
2  activesupport/lib/active_support/values/time_zone.rb
@@ -373,7 +373,7 @@ def us_zones
def require_tzinfo
- require 'tzinfo'
+ require 'tzinfo' unless defined?(::TZInfo)
rescue LoadError
$stderr.puts "You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install"
Please sign in to comment.
Something went wrong with that request. Please try again.