Permalink
Browse files

Fixes performance issue introduced in 3.0.6 (issue #6695)

  • Loading branch information...
1 parent 3d15019 commit a3639be4ed5e89b59c4ad0154d44f58e3e48d484 @stiang stiang committed with tenderlove Apr 14, 2011
Showing with 5 additions and 3 deletions.
  1. +5 −3 activerecord/lib/active_record/attribute_methods/read.rb
@@ -77,9 +77,11 @@ def define_read_method(symbol, attr_name, column)
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
def read_attribute(attr_name)
- send "_#{attr_name}"
- rescue NoMethodError
- _read_attribute attr_name
+ if respond_to? "_#{attr_name}"
+ send "_#{attr_name}"
+ else
+ _read_attribute attr_name
+ end
end
def _read_attribute(attr_name)

1 comment on commit a3639be

Contributor

lawrencepit commented on a3639be Jul 15, 2011

The problem with this implementation (compared to rails2) is that read_attribute is now in the top 5 responsible for creating the most objects (in a typical rails app), and thereby being a burden on the GC; i.e. it slows things down.

Please sign in to comment.