1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Perf: fields in pg gem causes an allocation, cache it

This commit is contained in:
Sam 2013-08-27 09:18:50 +10:00
parent e453aa91bb
commit 32b233c953

View file

@ -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