diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-28 15:32:53 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-28 15:32:53 -0700 |
commit | 6d44a1349ef23f8969eeec91b0facb0adf6df52b (patch) | |
tree | 319b076493f8610a3bd1495e58950f11c14f9e78 /lib/arel/algebra/header.rb | |
parent | 60b8a98c15186429a9bf216dbbae0f3b71b666bd (diff) | |
download | rails-6d44a1349ef23f8969eeec91b0facb0adf6df52b.tar.gz rails-6d44a1349ef23f8969eeec91b0facb0adf6df52b.tar.bz2 rails-6d44a1349ef23f8969eeec91b0facb0adf6df52b.zip |
PERF: fewer objects, less lambdas, less memory
Diffstat (limited to 'lib/arel/algebra/header.rb')
-rw-r--r-- | lib/arel/algebra/header.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/arel/algebra/header.rb b/lib/arel/algebra/header.rb index 3b8aea3422..dc779d53c3 100644 --- a/lib/arel/algebra/header.rb +++ b/lib/arel/algebra/header.rb @@ -4,9 +4,7 @@ module Arel def initialize(attrs = []) @attributes = attrs.to_ary - @names = Hash.new do |h,k| - h[k] = @attributes.detect { |a| a.named?(k) } - end + @names = {} end def each @@ -55,7 +53,8 @@ module Arel end def find_by_name(name) - @names[name.to_sym] + k = name.to_sym + @names[k] ||= @attributes.detect { |a| a.named?(k) } end def find_by_attribute(attr) |