aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-18 16:47:55 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-18 16:47:55 -0700
commit7feff4e7b52fbef356426d22257af161704315ad (patch)
treedb907c2bc27dc406d08513d40f8e75cd810a91f9 /lib
parent32ad530b825f4cdac51e579306548ca695471039 (diff)
downloadrails-7feff4e7b52fbef356426d22257af161704315ad.tar.gz
rails-7feff4e7b52fbef356426d22257af161704315ad.tar.bz2
rails-7feff4e7b52fbef356426d22257af161704315ad.zip
performance enhancements
Diffstat (limited to 'lib')
-rw-r--r--lib/arel/predicates.rb9
-rw-r--r--lib/arel/primitives/attribute.rb10
-rw-r--r--lib/arel/primitives/expression.rb10
-rw-r--r--lib/arel/primitives/value.rb4
-rw-r--r--lib/arel/relations/aggregation.rb4
-rw-r--r--lib/arel/relations/deletion.rb4
-rw-r--r--lib/arel/relations/grouping.rb6
-rw-r--r--lib/arel/relations/insertion.rb2
-rw-r--r--lib/arel/relations/join.rb25
-rw-r--r--lib/arel/relations/nil.rb2
-rw-r--r--lib/arel/relations/order.rb6
-rw-r--r--lib/arel/relations/projection.rb6
-rw-r--r--lib/arel/relations/selection.rb6
-rw-r--r--lib/arel/relations/skip.rb6
-rw-r--r--lib/arel/relations/table.rb4
-rw-r--r--lib/arel/relations/take.rb6
-rw-r--r--lib/arel/relations/update.rb6
17 files changed, 58 insertions, 58 deletions
diff --git a/lib/arel/predicates.rb b/lib/arel/predicates.rb
index b375f37ff4..f21376d4c9 100644
--- a/lib/arel/predicates.rb
+++ b/lib/arel/predicates.rb
@@ -1,8 +1,5 @@
module Arel
class Predicate
- def ==(other)
- self.class == other.class
- end
end
class Binary < Predicate
@@ -13,7 +10,9 @@ module Arel
end
def ==(other)
- super and @operand1 == other.operand1 and @operand2 == other.operand2
+ self.class === other and
+ @operand1 == other.operand1 and
+ @operand2 == other.operand2
end
def bind(relation)
@@ -28,7 +27,7 @@ module Arel
class Equality < Binary
def ==(other)
- Equality == other.class and
+ Equality === other and
((operand1 == other.operand1 and operand2 == other.operand2) or
(operand1 == other.operand2 and operand2 == other.operand1))
end
diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb
index 011b751a1d..ca1d31ffcf 100644
--- a/lib/arel/primitives/attribute.rb
+++ b/lib/arel/primitives/attribute.rb
@@ -30,11 +30,11 @@ module Arel
end
def ==(other)
- Attribute == other.class and
- name == other.name and
- @alias == other.alias and
- ancestor == other.ancestor and
- relation == other.relation
+ Attribute === other and
+ name == other.name and
+ @alias == other.alias and
+ ancestor == other.ancestor and
+ relation == other.relation
end
def original_relation
diff --git a/lib/arel/primitives/expression.rb b/lib/arel/primitives/expression.rb
index 696e3521be..9afafcce2f 100644
--- a/lib/arel/primitives/expression.rb
+++ b/lib/arel/primitives/expression.rb
@@ -17,11 +17,11 @@ module Arel
end
def ==(other)
- Expression == other.class and
- attribute == other.attribute and
- function_sql == other.function_sql and
- ancestor == other.ancestor and
- @alias == other.alias
+ Expression === other and
+ attribute == other.attribute and
+ function_sql == other.function_sql and
+ ancestor == other.ancestor and
+ @alias == other.alias
end
module Transformations
diff --git a/lib/arel/primitives/value.rb b/lib/arel/primitives/value.rb
index b4bddd0b0c..4509f13d17 100644
--- a/lib/arel/primitives/value.rb
+++ b/lib/arel/primitives/value.rb
@@ -17,8 +17,8 @@ module Arel
end
def ==(other)
- Value == other.class and
- value == other.value
+ Value === other and
+ value == other.value
end
def bind(relation)
diff --git a/lib/arel/relations/aggregation.rb b/lib/arel/relations/aggregation.rb
index a6f40be786..9a34ea5d89 100644
--- a/lib/arel/relations/aggregation.rb
+++ b/lib/arel/relations/aggregation.rb
@@ -19,8 +19,8 @@ module Arel
end
def ==(other)
- Aggregation == other.class and
- self.relation == other.relation
+ Aggregation === other and
+ self.relation == other.relation
end
end
diff --git a/lib/arel/relations/deletion.rb b/lib/arel/relations/deletion.rb
index 8c9d873a02..cd58771846 100644
--- a/lib/arel/relations/deletion.rb
+++ b/lib/arel/relations/deletion.rb
@@ -18,8 +18,8 @@ module Arel
end
def ==(other)
- Deletion == other.class and
- relation == other.relation
+ Deletion === other and
+ relation == other.relation
end
end
end \ No newline at end of file
diff --git a/lib/arel/relations/grouping.rb b/lib/arel/relations/grouping.rb
index 39b5942bcc..6d11299051 100644
--- a/lib/arel/relations/grouping.rb
+++ b/lib/arel/relations/grouping.rb
@@ -7,9 +7,9 @@ module Arel
end
def ==(other)
- Grouping == other.class and
- relation == other.relation and
- groupings == other.groupings
+ Grouping === other and
+ relation == other.relation and
+ groupings == other.groupings
end
def aggregation?
diff --git a/lib/arel/relations/insertion.rb b/lib/arel/relations/insertion.rb
index cc7fcb4fb0..16eb9b7555 100644
--- a/lib/arel/relations/insertion.rb
+++ b/lib/arel/relations/insertion.rb
@@ -20,7 +20,7 @@ module Arel
end
def ==(other)
- Insertion == other.class and
+ Insertion === other and
relation == other.relation and
record == other.record
end
diff --git a/lib/arel/relations/join.rb b/lib/arel/relations/join.rb
index 9cc9f95c81..81a157dc10 100644
--- a/lib/arel/relations/join.rb
+++ b/lib/arel/relations/join.rb
@@ -13,13 +13,15 @@ module Arel
end
def joins(environment, formatter = Sql::TableReference.new(environment))
- this_join = [
- join_sql,
- relation2.externalize.table_sql(formatter),
- ("ON" unless predicates.blank?),
- (ons + relation2.externalize.selects).collect { |p| p.bind(environment).to_sql(Sql::WhereClause.new(environment)) }.join(' AND ')
- ].compact.join(" ")
- [relation1.joins(environment), this_join, relation2.joins(environment)].compact.join(" ")
+ @joins ||= begin
+ this_join = [
+ join_sql,
+ relation2.externalize.table_sql(formatter),
+ ("ON" unless predicates.blank?),
+ (ons + relation2.externalize.selects).collect { |p| p.bind(environment).to_sql(Sql::WhereClause.new(environment)) }.join(' AND ')
+ ].compact.join(" ")
+ [relation1.joins(environment), this_join, relation2.joins(environment)].compact.join(" ")
+ end
end
def attributes
@@ -45,11 +47,10 @@ module Arel
end
def ==(other)
- Join == other.class and
- predicates == other.predicates and (
- (relation1 == other.relation1 and relation2 == other.relation2) or
- (relation2 == other.relation1 and relation1 == other.relation2)
- )
+ Join === other and
+ predicates == other.predicates and
+ relation1 == other.relation1 and
+ relation2 == other.relation2
end
end
diff --git a/lib/arel/relations/nil.rb b/lib/arel/relations/nil.rb
index c34fe71473..2dcfb47233 100644
--- a/lib/arel/relations/nil.rb
+++ b/lib/arel/relations/nil.rb
@@ -4,7 +4,7 @@ module Arel
def name; '' end
def ==(other)
- Nil == other.class
+ Nil === other
end
end
end \ No newline at end of file
diff --git a/lib/arel/relations/order.rb b/lib/arel/relations/order.rb
index 31032e871c..ebb4dc0668 100644
--- a/lib/arel/relations/order.rb
+++ b/lib/arel/relations/order.rb
@@ -11,9 +11,9 @@ module Arel
end
def ==(other)
- Order == other.class and
- relation == other.relation and
- orderings == other.orderings
+ Order === other and
+ relation == other.relation and
+ orderings == other.orderings
end
end
end \ No newline at end of file
diff --git a/lib/arel/relations/projection.rb b/lib/arel/relations/projection.rb
index 7eea63d808..d74f111271 100644
--- a/lib/arel/relations/projection.rb
+++ b/lib/arel/relations/projection.rb
@@ -15,9 +15,9 @@ module Arel
end
def ==(other)
- Projection == other.class and
- relation == other.relation and
- projections == other.projections
+ Projection === other and
+ relation == other.relation and
+ projections == other.projections
end
end
end \ No newline at end of file
diff --git a/lib/arel/relations/selection.rb b/lib/arel/relations/selection.rb
index 0c5956d2fc..fc4e94621a 100644
--- a/lib/arel/relations/selection.rb
+++ b/lib/arel/relations/selection.rb
@@ -13,9 +13,9 @@ module Arel
end
def ==(other)
- Selection == other.class and
- relation == other.relation and
- predicate == other.predicate
+ Selection === other and
+ relation == other.relation and
+ predicate == other.predicate
end
end
end \ No newline at end of file
diff --git a/lib/arel/relations/skip.rb b/lib/arel/relations/skip.rb
index 4686e03177..01ac4c7204 100644
--- a/lib/arel/relations/skip.rb
+++ b/lib/arel/relations/skip.rb
@@ -7,9 +7,9 @@ module Arel
end
def ==(other)
- Skip == other.class and
- relation == other.relation and
- skipped == other.skipped
+ Skip === other and
+ relation == other.relation and
+ skipped == other.skipped
end
end
end \ No newline at end of file
diff --git a/lib/arel/relations/table.rb b/lib/arel/relations/table.rb
index 06625dd52a..087028fb55 100644
--- a/lib/arel/relations/table.rb
+++ b/lib/arel/relations/table.rb
@@ -29,8 +29,8 @@ module Arel
end
def ==(other)
- Table == other.class and
- name == other.name
+ Table === other and
+ name == other.name
end
end
end \ No newline at end of file
diff --git a/lib/arel/relations/take.rb b/lib/arel/relations/take.rb
index 80aa62a878..0a49891aee 100644
--- a/lib/arel/relations/take.rb
+++ b/lib/arel/relations/take.rb
@@ -7,9 +7,9 @@ module Arel
end
def ==(other)
- Take == other.class and
- relation == other.relation and
- taken == other.taken
+ Take === other and
+ relation == other.relation and
+ taken == other.taken
end
end
end \ No newline at end of file
diff --git a/lib/arel/relations/update.rb b/lib/arel/relations/update.rb
index 486ad2ab12..8306a83aac 100644
--- a/lib/arel/relations/update.rb
+++ b/lib/arel/relations/update.rb
@@ -22,9 +22,9 @@ module Arel
end
def ==(other)
- Update == other.class and
- relation == other.relation and
- assignments == other.assignments
+ Update === other and
+ relation == other.relation and
+ assignments == other.assignments
end
end
end \ No newline at end of file