diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-11-03 12:14:53 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-11-03 12:14:53 -0200 |
commit | af9702c015caba73fa99782360b123a1debe6d81 (patch) | |
tree | b80e0574108f75a1f4e135903a2984f4aaa0b489 /activerecord/lib | |
parent | 4259cc0c5003c26f72105419c3d60e362f539040 (diff) | |
parent | 0488d0021190970c894b30bd2b4b05fbeaa75f83 (diff) | |
download | rails-af9702c015caba73fa99782360b123a1debe6d81.tar.gz rails-af9702c015caba73fa99782360b123a1debe6d81.tar.bz2 rails-af9702c015caba73fa99782360b123a1debe6d81.zip |
Merge pull request #17487 from pabloh/avoid_allocations
Avoid unnecessary allocations and method calls
Diffstat (limited to 'activerecord/lib')
4 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index 04a69ba446..bde23fc116 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -161,7 +161,7 @@ module ActiveRecord if scope.klass.primary_key count = scope.destroy_all.length else - scope.to_a.each do |record| + scope.each do |record| record._run_destroy_callbacks end diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index cff6798eb3..3357ed52e5 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -88,7 +88,7 @@ module ActiveRecord end def clear - cache.values.each do |hash| + cache.each_value do |hash| hash[:stmt].close end cache.clear diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 4756896ac5..1b5e3bdbac 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -115,7 +115,7 @@ module ActiveRecord end def clear - cache.values.each do |hash| + cache.each_value do |hash| dealloc hash[:stmt] end cache.clear diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 125a119b5f..db6421dacb 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -649,7 +649,7 @@ module ActiveRecord model_class end - reflection_class._reflections.values.each do |association| + reflection_class._reflections.each_value do |association| case association.macro when :belongs_to # Do not replace association name with association foreign key if they are named the same |