Skip to content

Commit

Permalink
Merge pull request #12037 from SamSaffron/mem_alloc
Browse files Browse the repository at this point in the history
Performance: Reduce memory allocations in Active Record
  • Loading branch information
tenderlove committed Aug 26, 2013
1 parent 82b3b69 commit cf4816e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Expand Up @@ -51,7 +51,7 @@ def #{attr_name}=(time)
def create_time_zone_conversion_attribute?(name, column)
time_zone_aware_attributes &&
!self.skip_time_zone_conversion_for_attributes.include?(name.to_sym) &&
[:datetime, :timestamp].include?(column.type)
(:datetime == column.type || :timestamp == column.type)
end
end
end
Expand Down
Expand Up @@ -139,7 +139,8 @@ def exec_query(sql, name = 'SQL', binds = [])
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|
Expand All @@ -148,7 +149,7 @@ def exec_query(sql, name = 'SQL', binds = [])
}
end

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

0 comments on commit cf4816e

Please sign in to comment.