提交 3e3d4d19 编写于 作者: E Ernie Miller 提交者: Aaron Patterson

Improve performance of grouping_any/grouping_all

上级 fc353baa
......@@ -163,21 +163,14 @@ def desc
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册