Skip to content
This repository
Browse code

Speed up timestamping a tad #1227 [skaen]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1327 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit c8b4cf65df48b7340dc8337cb23186c5e263bb2b 1 parent 977671c
David Heinemeier Hansson authored May 19, 2005
18  activerecord/lib/active_record/timestamp.rb
@@ -19,21 +19,23 @@ def self.append_features(base) # :nodoc:
19 19
     end    
20 20
       
21 21
     def create_with_timestamps #:nodoc:
  22
+      if record_timestamps
22 23
       t = ( self.class.default_timezone == :utc ? Time.now.utc : Time.now )
23  
-      write_attribute("created_at", t) if record_timestamps && respond_to?(:created_at) && created_at.nil?
24  
-      write_attribute("created_on", t) if record_timestamps && respond_to?(:created_on) && created_on.nil?
25  
-
26  
-      write_attribute("updated_at", t) if record_timestamps && respond_to?(:updated_at)
27  
-      write_attribute("updated_on", t) if record_timestamps && respond_to?(:updated_on)
  24
+        write_attribute('created_at', t) if respond_to?(:created_at) && created_at.nil?
  25
+        write_attribute('created_on', t) if respond_to?(:created_on) && created_on.nil?
28 26
       
  27
+        write_attribute('updated_at', t) if respond_to?(:updated_at)
  28
+        write_attribute('updated_on', t) if respond_to?(:updated_on)
  29
+      end
29 30
       create_without_timestamps
30 31
     end
31 32
 
32 33
     def update_with_timestamps #:nodoc:
  34
+      if record_timestamps
33 35
       t = ( self.class.default_timezone == :utc ? Time.now.utc : Time.now )
34  
-      write_attribute("updated_at", t) if record_timestamps && respond_to?(:updated_at)
35  
-      write_attribute("updated_on", t) if record_timestamps && respond_to?(:updated_on)
36  
-
  36
+        write_attribute('updated_at', t) if respond_to?(:updated_at)
  37
+        write_attribute('updated_on', t) if respond_to?(:updated_on)
  38
+      end
37 39
       update_without_timestamps
38 40
     end
39 41
   end 

0 notes on commit c8b4cf6

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