From 5e86ee1195eaf2242a5fdd35fce3790260e5e826 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Fri, 31 Aug 2018 00:06:12 +0900 Subject: Refactor `attributes_for_{create,update}` to avoid an extra allocation Use `delete_if` instead of `reject` to avoid an extra allocation. --- activerecord/lib/active_record/persistence.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'activerecord/lib/active_record/persistence.rb') diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 215b59f182..24af56cf0b 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -718,7 +718,6 @@ module ActiveRecord # Updates the associated record with values matching those of the instance attributes. # Returns the number of affected rows. def _update_record(attribute_names = self.attribute_names) - attribute_names &= self.class.column_names attribute_names = attributes_for_update(attribute_names) if attribute_names.empty? @@ -737,7 +736,6 @@ module ActiveRecord # Creates a record with values matching those of the instance attributes # and returns its id. def _create_record(attribute_names = self.attribute_names) - attribute_names &= self.class.column_names attribute_names = attributes_for_create(attribute_names) new_id = self.class._insert_record( -- cgit v1.2.3