From f45e08e524d63c54e2db8fa91fb739d676d58707 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 10 Sep 2016 22:28:05 +0900 Subject: Reduce array allocation when `where` with passed hash In most case `where` is called with passed hash. In the case initializing `binds` is unnecessary. --- activerecord/lib/active_record/relation/where_clause_factory.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/relation/where_clause_factory.rb b/activerecord/lib/active_record/relation/where_clause_factory.rb index dc00149130..1e7deeffad 100644 --- a/activerecord/lib/active_record/relation/where_clause_factory.rb +++ b/activerecord/lib/active_record/relation/where_clause_factory.rb @@ -7,8 +7,6 @@ module ActiveRecord end def build(opts, other) - binds = [] - case opts when String, Array parts = [klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))] @@ -26,7 +24,7 @@ module ActiveRecord raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})" end - WhereClause.new(parts, binds) + WhereClause.new(parts, binds || []) end protected -- cgit v1.2.3