diff options
-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 |