aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-09-10 22:28:05 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-09-10 22:28:05 +0900
commitf45e08e524d63c54e2db8fa91fb739d676d58707 (patch)
tree3e61944e47eaf8e0c9453ea007fa25ca6c59e85f /activerecord/lib/active_record
parentcf5f55cd30aef0f90300c7c8f333060fe258cd8a (diff)
downloadrails-f45e08e524d63c54e2db8fa91fb739d676d58707.tar.gz
rails-f45e08e524d63c54e2db8fa91fb739d676d58707.tar.bz2
rails-f45e08e524d63c54e2db8fa91fb739d676d58707.zip
Reduce array allocation when `where` with passed hash
In most case `where` is called with passed hash. In the case initializing `binds` is unnecessary.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/where_clause_factory.rb4
1 files changed, 1 insertions, 3 deletions
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