diff options
author | Ernie Miller <ernie@metautonomo.us> | 2011-04-19 00:05:19 +0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-19 00:20:29 +0800 |
commit | 3e3d4d197943d6fc30976021a0f125ba8eab1dd1 (patch) | |
tree | c241b38aedb24aca87ec1fe0c6f4c987ccb31171 /lib | |
parent | fc353baa803ba5ab2c11d71adcec358ea5c75f44 (diff) | |
download | rails-3e3d4d197943d6fc30976021a0f125ba8eab1dd1.tar.gz rails-3e3d4d197943d6fc30976021a0f125ba8eab1dd1.tar.bz2 rails-3e3d4d197943d6fc30976021a0f125ba8eab1dd1.zip |
Improve performance of grouping_any/grouping_all
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/predications.rb | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/arel/predications.rb b/lib/arel/predications.rb index 75c4c75855..7e2425e45f 100644 --- a/lib/arel/predications.rb +++ b/lib/arel/predications.rb @@ -163,21 +163,14 @@ module Arel private def grouping_any method_id, others - others = others.dup - first = send method_id, others.shift - - Nodes::Grouping.new others.inject(first) { |memo,expr| - Nodes::Or.new(memo, send(method_id, expr)) + nodes = others.map {|expr| send(method_id, expr)} + Nodes::Grouping.new nodes.inject { |memo,node| + Nodes::Or.new(memo, node) } end def grouping_all method_id, others - others = others.dup - first = send method_id, others.shift - - Nodes::Grouping.new others.inject(first) { |memo,expr| - Nodes::And.new([memo, send(method_id, expr)]) - } + Nodes::Grouping.new Nodes::And.new(others.map {|expr| send(method_id, expr)}) end end end |