aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-09 15:25:19 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-09 15:25:19 -0700
commit0cfb1de4583b5926bbb10de39d80d8537a7e6482 (patch)
tree0ff7cc761f2d81d543e71e5d3714a83dff89512b
parent752a06ea8d76a072a4cf51594f47d8a4c6c2edd6 (diff)
downloadrails-0cfb1de4583b5926bbb10de39d80d8537a7e6482.tar.gz
rails-0cfb1de4583b5926bbb10de39d80d8537a7e6482.tar.bz2
rails-0cfb1de4583b5926bbb10de39d80d8537a7e6482.zip
add some convenient methods for avoiding array allocations
-rw-r--r--activerecord/lib/active_record/associations/join_dependency.rb6
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_part.rb3
2 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb
index 4d1f7a1041..d0c920ce4c 100644
--- a/activerecord/lib/active_record/associations/join_dependency.rb
+++ b/activerecord/lib/active_record/associations/join_dependency.rb
@@ -76,17 +76,17 @@ module ActiveRecord
end
def reflections
- join_root.drop(1).map(&:reflection)
+ join_root.drop(1).map!(&:reflection)
end
def join_relation(relation)
- join_root.drop(1).inject(relation) do |rel,association|
+ join_root.inject(relation) do |rel,association|
association.join_relation(rel)
end
end
def join_constraints
- join_root.drop(1).flat_map(&:join_constraints)
+ join_root.flat_map(&:join_constraints)
end
def columns
diff --git a/activerecord/lib/active_record/associations/join_dependency/join_part.rb b/activerecord/lib/active_record/associations/join_dependency/join_part.rb
index 27304acceb..d536eaf613 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_part.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_part.rb
@@ -29,6 +29,9 @@ module ActiveRecord
@children = []
end
+ def join_constraints; []; end
+ def join_relation(rel); rel; end
+
def name
reflection.name
end