Skip to content

Commit

Permalink
Make sure require_tzinfo only calls Kernel#require if TZInfo isn't al…
Browse files Browse the repository at this point in the history
…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
toolmantim committed Sep 7, 2011
1 parent df21e3d commit d6d4740
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions activesupport/CHANGELOG
Original file line number Diff line number Diff line change
@@ -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)*
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/values/time_zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def us_zones
protected

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"
raise
Expand Down

0 comments on commit d6d4740

Please sign in to comment.