diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-06 16:14:50 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-06 16:14:50 -0700 |
commit | cf00da66924de0a4435391be70efe04ccfb12787 (patch) | |
tree | 6698922ae9c5aafbd45d0e1ecdb5d18d0fd377d1 | |
parent | c7b4f12d9339504b58431de0145d9a965008e650 (diff) | |
download | rails-cf00da66924de0a4435391be70efe04ccfb12787.tar.gz rails-cf00da66924de0a4435391be70efe04ccfb12787.tar.bz2 rails-cf00da66924de0a4435391be70efe04ccfb12787.zip |
PERF: reduce calls to Hash#[]
-rw-r--r-- | lib/arel/engines/sql/christener.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/arel/engines/sql/christener.rb b/lib/arel/engines/sql/christener.rb index 3c7fb0425e..b30883e47c 100644 --- a/lib/arel/engines/sql/christener.rb +++ b/lib/arel/engines/sql/christener.rb @@ -8,11 +8,11 @@ module Arel def name_for(relation) table = relation.table name = table.table_alias || table.name - @names[name] ||= [] + list = @names[name] ||= [] - @names[name] << table unless @names[name].include? table + list << table unless list.include? table - idx = @names[name].index table + idx = list.index table name + (idx == 0 ? '' : "_#{idx + 1}") end end |