diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2014-11-20 08:47:34 -0800 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2014-11-20 08:47:34 -0800 |
commit | 347c226078757a34b26ba589e99143b7ec0ab4ac (patch) | |
tree | 116a7da13e1ed55e4fad66537dba06b9eecb5def /activerecord/lib | |
parent | d56be864f61cc00eeff27ed42e7cec4194c5347f (diff) | |
parent | a668b09ee387bf241a3481a764a18a5c8a4df8cd (diff) | |
download | rails-347c226078757a34b26ba589e99143b7ec0ab4ac.tar.gz rails-347c226078757a34b26ba589e99143b7ec0ab4ac.tar.bz2 rails-347c226078757a34b26ba589e99143b7ec0ab4ac.zip |
Merge pull request #17669 from SamSaffron/optimise_memory
PERF: avoid string allocations
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index cb4e33f1b1..eb69943551 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -1059,8 +1059,13 @@ module ActiveRecord def build_select(arel, selects) if !selects.empty? expanded_select = selects.map do |field| - columns_hash.key?(field.to_s) ? arel_table[field] : field + if (Symbol === field || String === field) && columns_hash.key?(field.to_s) + arel_table[field] + else + field + end end + arel.project(*expanded_select) else arel.project(@klass.arel_table[Arel.star]) |