Permalink
Browse files

Merge pull request #12037 from SamSaffron/mem_alloc

Performance: Reduce memory allocations in Active Record
  • Loading branch information...
2 parents e453aa9 + 4ff8790 commit 76ba3604c9ad845476297844c5d81b0ffa181bee @tenderlove tenderlove committed Aug 26, 2013
@@ -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
@@ -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|
@@ -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

0 comments on commit 76ba360

Please sign in to comment.