diff options
author | Sam <sam.saffron@gmail.com> | 2013-08-27 09:18:50 +1000 |
---|---|---|
committer | Sam <sam.saffron@gmail.com> | 2013-08-27 09:18:50 +1000 |
commit | 32b233c95315f637a944a1a8f41cb188a452e859 (patch) | |
tree | 97cc7c424d7c2157a23d6828861381f8d2ada620 /activerecord | |
parent | e453aa91bb4639fdc0f0b97e9bc0ed4b3833d0d2 (diff) | |
download | rails-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.rb | 5 |
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 |