diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-29 14:55:57 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-29 14:55:57 -0700 |
commit | f171bc64a2fcb321284b10c0c454f16569505439 (patch) | |
tree | ca3d29212f682651b0c8fdbee9036de2dd88fcda /activerecord/lib/active_record | |
parent | aa054c35f7809b57ecb105e485e4436d9fe37b1b (diff) | |
download | rails-f171bc64a2fcb321284b10c0c454f16569505439.tar.gz rails-f171bc64a2fcb321284b10c0c454f16569505439.tar.bz2 rails-f171bc64a2fcb321284b10c0c454f16569505439.zip |
PERF: avoiding splat args and reducing function calls
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 13 |
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) |