diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-12 15:40:06 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-12 15:40:06 -0700 |
commit | fff47a5a5e92eccf949785231d1f6953d6fdc640 (patch) | |
tree | e7e651d680bacc1542883b6a1c6c2ef21c3f2d1d /lib | |
parent | ea111521b7eb7456934a283d96f6eb986322baf2 (diff) | |
download | rails-fff47a5a5e92eccf949785231d1f6953d6fdc640.tar.gz rails-fff47a5a5e92eccf949785231d1f6953d6fdc640.tar.bz2 rails-fff47a5a5e92eccf949785231d1f6953d6fdc640.zip |
some memoizing and hash equality performance optimizations
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/primitives/attribute.rb | 14 | ||||
-rw-r--r-- | lib/arel/relations/compound.rb | 2 | ||||
-rw-r--r-- | lib/arel/relations/relation.rb | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/lib/arel/primitives/attribute.rb b/lib/arel/primitives/attribute.rb index 78a519b35c..acc4d86a80 100644 --- a/lib/arel/primitives/attribute.rb +++ b/lib/arel/primitives/attribute.rb @@ -9,8 +9,8 @@ module Arel @relation, @name, @alias, @ancestor = relation, name, options[:alias], options[:ancestor] end - def alias_or_name - @alias || name + def named?(hypothetical_name) + (@alias || name).to_s == hypothetical_name.to_s end def aggregation? @@ -57,12 +57,12 @@ module Arel include Transformations module Congruence - def self.included(klass) - klass.hash_on :name - end - + # def self.included(klass) + # klass.hash_on :name + # end + # def history - [self] + (ancestor ? [ancestor, ancestor.history].flatten : []) + @history ||= [self] + (ancestor ? [ancestor, ancestor.history].flatten : []) end def match?(other) diff --git a/lib/arel/relations/compound.rb b/lib/arel/relations/compound.rb index 7b6f3a46f8..663711760c 100644 --- a/lib/arel/relations/compound.rb +++ b/lib/arel/relations/compound.rb @@ -8,7 +8,7 @@ module Arel :to => :relation def attributes - relation.attributes.collect { |a| a.bind(self) } + @attributes ||= relation.attributes.collect { |a| a.bind(self) } end end end
\ No newline at end of file diff --git a/lib/arel/relations/relation.rb b/lib/arel/relations/relation.rb index 4653323514..b2f811cea2 100644 --- a/lib/arel/relations/relation.rb +++ b/lib/arel/relations/relation.rb @@ -136,7 +136,7 @@ module Arel end def find_attribute_matching_name(name) - attributes.detect { |a| a.alias_or_name.to_s == name.to_s } + attributes.detect { |a| a.named?(name) } end # TESTME - added relation_for(x)[x] because of AR |