Skip to content
This repository
Browse code

Merge pull request #12037 from SamSaffron/mem_alloc

Performance: Reduce memory allocations in Active Record
  • Loading branch information...
commit cf4816e6e45bc338b43a0087ebbe9510530b5fbc 1 parent 82b3b69
Aaron Patterson authored August 26, 2013
2  activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
@@ -51,7 +51,7 @@ def #{attr_name}=(time)
51 51
         def create_time_zone_conversion_attribute?(name, column)
52 52
           time_zone_aware_attributes &&
53 53
             !self.skip_time_zone_conversion_for_attributes.include?(name.to_sym) &&
54  
-            [:datetime, :timestamp].include?(column.type)
  54
+            (:datetime == column.type || :timestamp == column.type)
55 55
         end
56 56
       end
57 57
     end
5  activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
@@ -139,7 +139,8 @@ def exec_query(sql, name = 'SQL', binds = [])
139 139
                                     exec_cache(sql, binds)
140 140
 
141 141
             types = {}
142  
-            result.fields.each_with_index do |fname, i|
  142
+            fields = result.fields
  143
+            fields.each_with_index do |fname, i|
143 144
               ftype = result.ftype i
144 145
               fmod  = result.fmod i
145 146
               types[fname] = OID::TYPE_MAP.fetch(ftype, fmod) { |oid, mod|
@@ -148,7 +149,7 @@ def exec_query(sql, name = 'SQL', binds = [])
148 149
               }
149 150
             end
150 151
 
151  
-            ret = ActiveRecord::Result.new(result.fields, result.values, types)
  152
+            ret = ActiveRecord::Result.new(fields, result.values, types)
152 153
             result.clear
153 154
             return ret
154 155
           end

0 notes on commit cf4816e

Please sign in to comment.
Something went wrong with that request. Please try again.