diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-30 09:24:28 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-30 09:24:28 -0700 |
commit | 19926cf6d3304b713ede84ae931e25700fd0db81 (patch) | |
tree | bb020c632cf934e43fcc8208a8bec759d7139128 | |
parent | b176daecddb81849c5db15472bd1b6847900e75c (diff) | |
download | rails-19926cf6d3304b713ede84ae931e25700fd0db81.tar.gz rails-19926cf6d3304b713ede84ae931e25700fd0db81.tar.bz2 rails-19926cf6d3304b713ede84ae931e25700fd0db81.zip |
PERF: fewer objects, short circuit unless necessary
-rw-r--r-- | lib/arel/algebra/relations/relation.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb index eeb5918f4b..97aa779926 100644 --- a/lib/arel/algebra/relations/relation.rb +++ b/lib/arel/algebra/relations/relation.rb @@ -38,8 +38,11 @@ module Arel end end - def to_sql(formatter = Sql::SelectStatement.new(self)) - formatter.select compiler.select_sql, self + def to_sql(formatter = nil) + sql = compiler.select_sql + + return sql unless formatter + formatter.select sql, self end def christener @@ -76,7 +79,7 @@ module Arel end def from_clauses - sources.blank? ? table_sql(Sql::TableReference.new(self)) : sources + sources.empty? ? table_sql : sources end def where_clauses |