Skip to content

Commit

Permalink
Perf: fields in pg gem causes an allocation, cache it
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Aug 26, 2013
1 parent e453aa9 commit 32b233c
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def exec_query(sql, name = 'SQL', binds = [])
exec_cache(sql, binds) exec_cache(sql, binds)


types = {} types = {}
result.fields.each_with_index do |fname, i| fields = result.fields
fields.each_with_index do |fname, i|
ftype = result.ftype i ftype = result.ftype i
fmod = result.fmod i fmod = result.fmod i
types[fname] = OID::TYPE_MAP.fetch(ftype, fmod) { |oid, mod| types[fname] = OID::TYPE_MAP.fetch(ftype, fmod) { |oid, mod|
Expand All @@ -148,7 +149,7 @@ def exec_query(sql, name = 'SQL', binds = [])
} }
end end


ret = ActiveRecord::Result.new(result.fields, result.values, types) ret = ActiveRecord::Result.new(fields, result.values, types)
result.clear result.clear
return ret return ret
end end
Expand Down

0 comments on commit 32b233c

Please sign in to comment.