aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/merger.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-10-12 14:34:04 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-10-12 16:37:12 -0700
commit3a6dfca7f5f5bd45cea2f6ac348178e72423e1d5 (patch)
tree054424a2c6a67c76d7dc4d03b7e5b8f2d80d8221 /activerecord/lib/active_record/relation/merger.rb
parente68b97a4b65787711e50aa1565b4dd0077a00d6d (diff)
downloadrails-3a6dfca7f5f5bd45cea2f6ac348178e72423e1d5.tar.gz
rails-3a6dfca7f5f5bd45cea2f6ac348178e72423e1d5.tar.bz2
rails-3a6dfca7f5f5bd45cea2f6ac348178e72423e1d5.zip
Speed up relation merging by reducing calls to Array#-
before: Calculating ------------------------------------- ar 83 i/100ms ------------------------------------------------- ar 832.1 (±4.0%) i/s - 4233 in 5.096611s after: Calculating ------------------------------------- ar 87 i/100ms ------------------------------------------------- ar 839.0 (±9.3%) i/s - 4176 in 5.032782s Benchmark: require 'config/environment' require 'benchmark/ips' GC.disable unless User.find_by_login('tater') u = User.new u.login = 'tater' u.save! end def active_record user = User.find_by_login('tater') starred = user.starred_items.count end active_record Benchmark.ips do |x| x.report("ar") { active_record } end
Diffstat (limited to 'activerecord/lib/active_record/relation/merger.rb')
-rw-r--r--activerecord/lib/active_record/relation/merger.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb
index e5b50673da..951eabe427 100644
--- a/activerecord/lib/active_record/relation/merger.rb
+++ b/activerecord/lib/active_record/relation/merger.rb
@@ -39,10 +39,12 @@ module ActiveRecord
@values = other.values
end
+ NORMAL_VALUES = Relation::SINGLE_VALUE_METHODS +
+ Relation::MULTI_VALUE_METHODS -
+ [:where, :order, :bind, :reverse_order, :lock, :create_with, :reordering, :from] # :nodoc:
+
def normal_values
- Relation::SINGLE_VALUE_METHODS +
- Relation::MULTI_VALUE_METHODS -
- [:where, :order, :bind, :reverse_order, :lock, :create_with, :reordering, :from]
+ NORMAL_VALUES
end
def merge