aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-29 14:55:57 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-29 14:55:57 -0700
commitf171bc64a2fcb321284b10c0c454f16569505439 (patch)
treeca3d29212f682651b0c8fdbee9036de2dd88fcda /activerecord/lib
parentaa054c35f7809b57ecb105e485e4436d9fe37b1b (diff)
downloadrails-f171bc64a2fcb321284b10c0c454f16569505439.tar.gz
rails-f171bc64a2fcb321284b10c0c454f16569505439.tar.bz2
rails-f171bc64a2fcb321284b10c0c454f16569505439.zip
PERF: avoiding splat args and reducing function calls
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb13
1 files changed, 5 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 0593897fa5..05962f409f 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -47,9 +47,9 @@ module ActiveRecord
clone.tap {|r| r.joins_values += args if args.present? }
end
- def where(*args)
- value = build_where(*args)
- clone.tap {|r| r.where_values += Array.wrap(value) if value.present? }
+ def where(opts, other = nil)
+ value = build_where(opts, other)
+ value ? clone : clone.tap {|r| r.where_values += Array.wrap(value) }
end
def having(*args)
@@ -166,13 +166,10 @@ module ActiveRecord
arel
end
- def build_where(*args)
- return if args.blank?
-
- opts = args.first
+ def build_where(opts, other = nil)
case opts
when String, Array
- @klass.send(:sanitize_sql, args.size > 1 ? args : opts)
+ @klass.send(:sanitize_sql, other ? [opts, other] : opts)
when Hash
attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts)
PredicateBuilder.new(table.engine).build_from_hash(attributes, table)