From a45015d0c81a39a848b3fe7dc13920c89a27a2f4 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Mon, 2 Mar 2015 11:02:02 -0500 Subject: Remove !has_transactional_callbacks? check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We only set the state on the record if that condition is `false` in the first place, so we dont need to call that again. Also that call is expensive, follow benchmark with before and after this change: ``` Calculating ------------------------------------- persisted? 15.272k i/100ms ------------------------------------------------- persisted? 350.119k (± 4.6%) i/s - 1.756M ``` ``` Calculating ------------------------------------- persisted? 25.988k i/100ms ------------------------------------------------- persisted? 1.294M (± 5.3%) i/s - 6.445M ``` (benchmark borrowed from 57d35b2bf9e48173a5f97ccff5e6897f0c46411f) --- activerecord/lib/active_record/transactions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 91ea81f2d2..8199bd4714 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -473,7 +473,7 @@ module ActiveRecord end def update_attributes_from_transaction_state(transaction_state) - if transaction_state && transaction_state.finalized? && !has_transactional_callbacks? + if transaction_state && transaction_state.finalized? restore_transaction_record_state if transaction_state.rolledback? clear_transaction_record_state end -- cgit v1.2.3