diff options
author | Arthur Neves <arthurnn@gmail.com> | 2015-03-02 11:02:02 -0500 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2015-03-02 11:02:02 -0500 |
commit | a45015d0c81a39a848b3fe7dc13920c89a27a2f4 (patch) | |
tree | ed7f178240ba35de257ff240a5214fafd629ce5a /activerecord/lib | |
parent | f9ed46bf5071545cce629cc6164029906cb2eb36 (diff) | |
download | rails-a45015d0c81a39a848b3fe7dc13920c89a27a2f4.tar.gz rails-a45015d0c81a39a848b3fe7dc13920c89a27a2f4.tar.bz2 rails-a45015d0c81a39a848b3fe7dc13920c89a27a2f4.zip |
Remove !has_transactional_callbacks? check
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)
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/transactions.rb | 2 |
1 files changed, 1 insertions, 1 deletions
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 |