From e2b49b203f2cb6cef93283f14838f21bf6ffb4a2 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Mon, 29 Sep 2014 16:07:18 +0200 Subject: Use Hash#each_key instead of Hash#keys.each Hash#keys.each allocates an array of keys; Hash#each_key iterates through the keys without allocating a new array. This is the reason why Hash#each_key exists. --- activerecord/lib/active_record/fixtures.rb | 2 +- activerecord/lib/active_record/railties/databases.rake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 4044f5f7b2..44cc1a079f 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -525,7 +525,7 @@ module ActiveRecord conn = fs.model_class.respond_to?(:connection) ? fs.model_class.connection : connection table_rows = fs.table_rows - table_rows.keys.each do |table| + table_rows.each_key do |table| conn.delete "DELETE FROM #{conn.quote_table_name(table)}", 'Fixture Delete' end diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 458862a538..44765bd050 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -215,7 +215,7 @@ db_namespace = namespace :db do Dir["#{base_dir}/**/*.yml"].each do |file| if data = YAML::load(ERB.new(IO.read(file)).result) - data.keys.each do |key| + data.each_key do |key| key_id = ActiveRecord::FixtureSet.identify(key) if key == label || key_id == id.to_i -- cgit v1.2.3