提交 f171bc64 编写于 作者: A Aaron Patterson

PERF: avoiding splat args and reducing function calls

上级 aa054c35
...@@ -47,9 +47,9 @@ def joins(*args) ...@@ -47,9 +47,9 @@ def joins(*args)
clone.tap {|r| r.joins_values += args if args.present? } clone.tap {|r| r.joins_values += args if args.present? }
end end
def where(*args) def where(opts, other = nil)
value = build_where(*args) value = build_where(opts, other)
clone.tap {|r| r.where_values += Array.wrap(value) if value.present? } value ? clone : clone.tap {|r| r.where_values += Array.wrap(value) }
end end
def having(*args) def having(*args)
...@@ -166,13 +166,10 @@ def build_arel ...@@ -166,13 +166,10 @@ def build_arel
arel arel
end end
def build_where(*args) def build_where(opts, other = nil)
return if args.blank?
opts = args.first
case opts case opts
when String, Array when String, Array
@klass.send(:sanitize_sql, args.size > 1 ? args : opts) @klass.send(:sanitize_sql, other ? [opts, other] : opts)
when Hash when Hash
attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts) attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts)
PredicateBuilder.new(table.engine).build_from_hash(attributes, table) PredicateBuilder.new(table.engine).build_from_hash(attributes, table)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册