diff options
author | Michael Koziarski <michael@koziarski.com> | 2008-02-14 20:06:25 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-02-14 20:06:25 +0000 |
commit | 838b02450ad3308c02a347d5f274b530f7a4a161 (patch) | |
tree | 2f7597eff6a84eb15de5085a852c56b2f8ce589e /activerecord | |
parent | 039f724c7b48f07181a45dab0b8643d0207d69f5 (diff) | |
download | rails-838b02450ad3308c02a347d5f274b530f7a4a161.tar.gz rails-838b02450ad3308c02a347d5f274b530f7a4a161.tar.bz2 rails-838b02450ad3308c02a347d5f274b530f7a4a161.zip |
Optimisation for BigDecimal conversion code. Closes #11110 [adymo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8870 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index fb403bf2ee..2e6adfa916 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -4,6 +4,8 @@ * Improve associations performance by avoiding named block arguments. #11109 [adymo] +* Optimise the BigDecimal conversion code. #11110 [adymo] + * Introduce the :readonly option to all associations. Records from the association cannot be saved. #11084 [miloops] * Multiparameter attributes for time columns fail over to DateTime when out of range of Time [Geoff Buesing] diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 8b2f3ad5d4..f7ee7ac7fd 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -144,7 +144,10 @@ module ActiveRecord # convert something to a BigDecimal def value_to_decimal(value) - if value.is_a?(BigDecimal) + # Using .class is faster than .is_a? and + # subclasses of BigDecimal will be handled + # in the else clause + if value.class == BigDecimal value elsif value.respond_to?(:to_d) value.to_d |