diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-21 20:32:00 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-21 20:32:00 -0700 |
commit | 27be777888cfefc6667c1d3b4c284cf1d0b67208 (patch) | |
tree | 2559966a879e87e596b0787030a7a86df6ed5489 | |
parent | e66bf6f5e3085014976ff8fa3981813b77510b69 (diff) | |
download | rails-27be777888cfefc6667c1d3b4c284cf1d0b67208.tar.gz rails-27be777888cfefc6667c1d3b4c284cf1d0b67208.tar.bz2 rails-27be777888cfefc6667c1d3b4c284cf1d0b67208.zip |
avoid a hash lookup
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index ff1a3f47b7..1af661c14f 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1962,13 +1962,13 @@ module ActiveRecord construct(parent, association, joins, row) end when Hash - associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name| + associations.sort_by { |k,_| k.to_s }.each do |name, assoc| join = joins.detect{|j| j.reflection.name.to_s == name.to_s && j.parent_table_name == parent.class.table_name } raise(ConfigurationError, "No such association") if join.nil? association = construct_association(parent, join, row) joins.delete(join) - construct(association, associations[name], joins, row) if association + construct(association, assoc, joins, row) if association end else raise ConfigurationError, associations.inspect |