diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-18 15:33:19 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-18 15:52:57 -0800 |
commit | c107849a997f1014d2e28ce394c3d9ccb3a1f50c (patch) | |
tree | 9a372eda4c6dd7a5ba4336d86fb6c07cdbe11fbf /activerecord | |
parent | f3a5995bbf7a46f5b94e830f97908a3a9314d46e (diff) | |
download | rails-c107849a997f1014d2e28ce394c3d9ccb3a1f50c.tar.gz rails-c107849a997f1014d2e28ce394c3d9ccb3a1f50c.tar.bz2 rails-c107849a997f1014d2e28ce394c3d9ccb3a1f50c.zip |
reduce objects, reduce loops and function calls while building the conditional
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/association_preload.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index 3fb3642125..8e71c6eec5 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -385,7 +385,7 @@ module ActiveRecord conditions << table["#{interface}_type"].eq(base_class.sti_name) end - conditions += append_conditions(reflection, preload_options) + conditions.concat append_conditions(reflection, preload_options) find_options = { :select => preload_options[:select] || options[:select] || table[Arel.star], @@ -397,9 +397,7 @@ module ActiveRecord associated_records(ids) do |some_ids| method = in_or_equal(some_ids) - where = conditions.inject(table[key].send(*method)) do |ast, cond| - ast.and cond - end + where = table.create_and(conditions + [table[key].send(*method)]) reflection.klass.scoped.apply_finder_options(find_options.merge(:conditions => where)).to_a end |