Skip to content
This repository
Browse code

Optimisation for BigDecimal conversion code. Closes #11110 [adymo]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8870 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 838b02450ad3308c02a347d5f274b530f7a4a161 1 parent 039f724
Michael Koziarski NZKoz authored
2  activerecord/CHANGELOG
@@ -4,6 +4,8 @@
4 4
5 5 * Improve associations performance by avoiding named block arguments. #11109 [adymo]
6 6
  7 +* Optimise the BigDecimal conversion code. #11110 [adymo]
  8 +
7 9 * Introduce the :readonly option to all associations. Records from the association cannot be saved. #11084 [miloops]
8 10
9 11 * Multiparameter attributes for time columns fail over to DateTime when out of range of Time [Geoff Buesing]
5 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -144,7 +144,10 @@ def value_to_boolean(value)
144 144
145 145 # convert something to a BigDecimal
146 146 def value_to_decimal(value)
147   - if value.is_a?(BigDecimal)
  147 + # Using .class is faster than .is_a? and
  148 + # subclasses of BigDecimal will be handled
  149 + # in the else clause
  150 + if value.class == BigDecimal
148 151 value
149 152 elsif value.respond_to?(:to_d)
150 153 value.to_d

0 comments on commit 838b024

Please sign in to comment.
Something went wrong with that request. Please try again.