diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-07-10 09:50:10 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-07-10 09:53:49 +0900 |
commit | d41ec8180d3df391e5fc0189f499d8689ca27e03 (patch) | |
tree | 1c7a506ecac02739351c3bcc9eacfb0e8a5bb025 /activerecord | |
parent | a4f16d9328933dff415ad4e51ca84d6de9bbb9ca (diff) | |
download | rails-d41ec8180d3df391e5fc0189f499d8689ca27e03.tar.gz rails-d41ec8180d3df391e5fc0189f499d8689ca27e03.tar.bz2 rails-d41ec8180d3df391e5fc0189f499d8689ca27e03.zip |
Avoid unneeded expanded column aliases array caching
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency/join_part.rb | 4 |
2 files changed, 5 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index d316db2145..b76005b587 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -14,10 +14,8 @@ module ActiveRecord i[column.name] = column.alias } } - @name_and_alias_cache = tables.each_with_object({}) { |table, h| - h[table.node] = table.columns.map { |column| - [column.name, column.alias] - } + @columns_cache = tables.each_with_object({}) { |table, h| + h[table.node] = table.columns } end @@ -25,9 +23,8 @@ module ActiveRecord @tables.flat_map(&:column_aliases) end - # An array of [column_name, alias] pairs for the table def column_aliases(node) - @name_and_alias_cache[node] + @columns_cache[node] end def column_alias(node, column) diff --git a/activerecord/lib/active_record/associations/join_dependency/join_part.rb b/activerecord/lib/active_record/associations/join_dependency/join_part.rb index 3cabb21983..3ad72a3646 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_part.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_part.rb @@ -54,8 +54,8 @@ module ActiveRecord length = column_names_with_alias.length while index < length - column_name, alias_name = column_names_with_alias[index] - hash[column_name] = row[alias_name] + column = column_names_with_alias[index] + hash[column.name] = row[column.alias] index += 1 end |