From 2147f35df251f215d845e870f21fd4010976eba3 Mon Sep 17 00:00:00 2001 From: Tim Lucas Date: Wed, 7 Sep 2011 14:21:18 +0300 Subject: Make sure require_tzinfo only calls Kernel#require if TZInfo isn't already 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) --- activesupport/lib/active_support/values/time_zone.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 4fb487ade1..35f400f9df 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -371,7 +371,7 @@ module ActiveSupport 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 -- cgit v1.2.3