aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSam <sam.saffron@gmail.com>2013-08-27 09:18:50 +1000
committerSam <sam.saffron@gmail.com>2013-08-27 09:18:50 +1000
commit32b233c95315f637a944a1a8f41cb188a452e859 (patch)
tree97cc7c424d7c2157a23d6828861381f8d2ada620 /activerecord
parente453aa91bb4639fdc0f0b97e9bc0ed4b3833d0d2 (diff)
downloadrails-32b233c95315f637a944a1a8f41cb188a452e859.tar.gz
rails-32b233c95315f637a944a1a8f41cb188a452e859.tar.bz2
rails-32b233c95315f637a944a1a8f41cb188a452e859.zip
Perf: fields in pg gem causes an allocation, cache it
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
index 751655e61c..527d13b9b0 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
@@ -139,7 +139,8 @@ module ActiveRecord
exec_cache(sql, binds)
types = {}
- result.fields.each_with_index do |fname, i|
+ fields = result.fields
+ fields.each_with_index do |fname, i|
ftype = result.ftype i
fmod = result.fmod i
types[fname] = OID::TYPE_MAP.fetch(ftype, fmod) { |oid, mod|
@@ -148,7 +149,7 @@ module ActiveRecord
}
end
- ret = ActiveRecord::Result.new(result.fields, result.values, types)
+ ret = ActiveRecord::Result.new(fields, result.values, types)
result.clear
return ret
end