summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJacob Kjeldahl <jkj@nettopower.dk>2016-07-05 10:08:30 +0200
committerJacob Kjeldahl <jkj@nettopower.dk>2016-07-05 10:08:30 +0200
commit5f027baca5b1e4f23c2c800be083d30f95d5a8a4 (patch)
tree5a9bb22ca5ed1684d18b63e2c779eb37ae18f13d /lib
parentb1ad4371ef81de68821af202ca10083cc3375ef4 (diff)
downloadpsych-5f027baca5b1e4f23c2c800be083d30f95d5a8a4.zip
Skips multiple requires of bigdecimal and date
The extra requires one pr. bigdecimal or date in the YAML being loaded was taking a lot of time when used in a Rails environment. For instance it took a file containing ~10.000 big decimals 20 seconds to load, and with this change it takes 2.5 seconds
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/visitors/to_ruby.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb
index c061da2..fd1c8e6 100644
--- a/lib/psych/visitors/to_ruby.rb
+++ b/lib/psych/visitors/to_ruby.rb
@@ -70,11 +70,11 @@ module Psych
o.value
end
when '!ruby/object:BigDecimal'
- require 'bigdecimal'
+ require 'bigdecimal' unless defined? BigDecimal
class_loader.big_decimal._load o.value
when "!ruby/object:DateTime"
class_loader.date_time
- require 'date'
+ require 'date' unless defined? DateTime
@ss.parse_time(o.value).to_datetime
when '!ruby/encoding'
::Encoding.find o.value