aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-12 15:50:07 -0700
committerNick Kallen <nkallen@nick-kallens-computer-2.local>2008-05-12 15:50:07 -0700
commit562a0bf634bd61f61ebb0145d7626fb484e13c53 (patch)
treea19556bf59bbdd4539a232588cb325bda1acce4f
parentfff47a5a5e92eccf949785231d1f6953d6fdc640 (diff)
downloadrails-562a0bf634bd61f61ebb0145d7626fb484e13c53.tar.gz
rails-562a0bf634bd61f61ebb0145d7626fb484e13c53.tar.bz2
rails-562a0bf634bd61f61ebb0145d7626fb484e13c53.zip
some slight performance improvements
-rw-r--r--lib/arel/primitives/attribute.rb8
-rw-r--r--lib/arel/relations/join.rb8
-rw-r--r--lib/arel/relations/recursion.rb2
-rw-r--r--lib/arel/relations/relation.rb3
4 files changed, 10 insertions, 11 deletions
diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb
index acc4d86a80..39de11be26 100644
--- a/lib/arel/primitives/attribute.rb
+++ b/lib/arel/primitives/attribute.rb
@@ -24,6 +24,10 @@ module Arel
def original_relation
relation.relation_for(self)
end
+
+ def original_attribute
+ original_relation[self]
+ end
def format(object)
object.to_sql(formatter)
@@ -57,10 +61,6 @@ module Arel
include Transformations
module Congruence
- # def self.included(klass)
- # klass.hash_on :name
- # end
- #
def history
@history ||= [self] + (ancestor ? [ancestor, ancestor.history].flatten : [])
end
diff --git a/lib/arel/relations/join.rb b/lib/arel/relations/join.rb
index c1c3150629..b3452968e4 100644
--- a/lib/arel/relations/join.rb
+++ b/lib/arel/relations/join.rb
@@ -44,15 +44,15 @@ module Arel
end
def relation_for(attribute)
- [externalize(relation1), externalize(relation2)].max do |r1, r2|
- o1, o2 = r1.relation_for(attribute), r2.relation_for(attribute)
- a1, a2 = o1 && o1[attribute], o2 && o2[attribute]
+ [externalize(relation1).relation_for(attribute), externalize(relation2).relation_for(attribute)].max do |r1, r2|
+ a1, a2 = r1 && r1[attribute], r2 && r2[attribute]
attribute / a1 <=> attribute / a2
- end.relation_for(attribute)
+ end
end
private
+ # FIXME - make instance method
def externalize(relation)
relation.aggregation?? Aggregation.new(relation) : relation
end
diff --git a/lib/arel/relations/recursion.rb b/lib/arel/relations/recursion.rb
index 2c6024dc30..90976c702b 100644
--- a/lib/arel/relations/recursion.rb
+++ b/lib/arel/relations/recursion.rb
@@ -6,7 +6,7 @@ module Arel
end
def relation_for(attribute)
- self[attribute] and self
+ self
end
def table_sql(formatter = Sql::TableReference.new(self))
diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb
index b2f811cea2..db7d746c79 100644
--- a/lib/arel/relations/relation.rb
+++ b/lib/arel/relations/relation.rb
@@ -142,8 +142,7 @@ module Arel
# TESTME - added relation_for(x)[x] because of AR
def find_attribute_matching_attribute(attribute)
attributes.select { |a| a.match?(attribute) }.max do |a1, a2|
- # FIXME relation_for(a1)[a1] should be a1.original or something
- (attribute / relation_for(a1)[a1]) <=> (attribute / relation_for(a2)[a2])
+ (attribute / a1.original_attribute) <=> (attribute / a2.original_attribute)
end
end