From cf00da66924de0a4435391be70efe04ccfb12787 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 6 Aug 2010 16:14:50 -0700 Subject: PERF: reduce calls to Hash#[] --- lib/arel/engines/sql/christener.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/arel') 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 -- cgit v1.2.3