aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2014-11-20 08:47:34 -0800
committerSean Griffin <sean@seantheprogrammer.com>2014-11-20 08:47:34 -0800
commit347c226078757a34b26ba589e99143b7ec0ab4ac (patch)
tree116a7da13e1ed55e4fad66537dba06b9eecb5def /activerecord
parentd56be864f61cc00eeff27ed42e7cec4194c5347f (diff)
parenta668b09ee387bf241a3481a764a18a5c8a4df8cd (diff)
downloadrails-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')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb7
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])