From d108288c2f684233298f97f18ac00de0b016deaa Mon Sep 17 00:00:00 2001
From: Dillon Welch <daw0328@gmail.com>
Date: Thu, 29 Mar 2018 19:29:55 -0700
Subject: Turn on performance based cops

Use attr_reader/attr_writer instead of methods

method is 12% slower

Use flat_map over map.flatten(1)

flatten is 66% slower

Use hash[]= instead of hash.merge! with single arguments

merge! is 166% slower

See https://github.com/rails/rails/pull/32337 for more conversation
---
 activemodel/test/cases/dirty_test.rb | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

(limited to 'activemodel')

diff --git a/activemodel/test/cases/dirty_test.rb b/activemodel/test/cases/dirty_test.rb
index b120e68027..b38d84fff2 100644
--- a/activemodel/test/cases/dirty_test.rb
+++ b/activemodel/test/cases/dirty_test.rb
@@ -14,37 +14,23 @@ class DirtyTest < ActiveModel::TestCase
       @status = "initialized"
     end
 
-    def name
-      @name
-    end
+    attr_reader :name, :color, :size, :status
 
     def name=(val)
       name_will_change!
       @name = val
     end
 
-    def color
-      @color
-    end
-
     def color=(val)
       color_will_change! unless val == @color
       @color = val
     end
 
-    def size
-      @size
-    end
-
     def size=(val)
       attribute_will_change!(:size) unless val == @size
       @size = val
     end
 
-    def status
-      @status
-    end
-
     def status=(val)
       status_will_change! unless val == @status
       @status = val
-- 
cgit v1.2.3