Permalink
Browse files

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...
1 parent 039f724 commit 838b02450ad3308c02a347d5f274b530f7a4a161 @NZKoz NZKoz committed Feb 14, 2008
View
@@ -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]
@@ -144,7 +144,10 @@ def value_to_boolean(value)
# 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

0 comments on commit 838b024

Please sign in to comment.