diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-06-24 01:37:58 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-06-24 02:04:00 -0700 |
commit | cdb8609c64ed7db7ea91cdcd4bcb4b400f7dfe07 (patch) | |
tree | 1abfc091b41bb7dc5d31452cc4dac3a16a72bc7f /railties | |
parent | 60ab9255f0cb09ee5d2891878f715f301ad7a213 (diff) | |
download | rails-cdb8609c64ed7db7ea91cdcd4bcb4b400f7dfe07.tar.gz rails-cdb8609c64ed7db7ea91cdcd4bcb4b400f7dfe07.tar.bz2 rails-cdb8609c64ed7db7ea91cdcd4bcb4b400f7dfe07.zip |
Speed up boot by tsorting as infrequently as possible
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/application.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/initializable.rb | 9 | ||||
-rw-r--r-- | railties/test/railties/engine_test.rb | 2 |
3 files changed, 4 insertions, 9 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index aabe86715c..5813c5757d 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -178,7 +178,7 @@ module Rails railties.all { |r| initializers += r.initializers } initializers += super initializers += Finisher.initializers_for(self) - initializers + Collection.new(initializers) end protected diff --git a/railties/lib/rails/initializable.rb b/railties/lib/rails/initializable.rb index 9a82e051e7..78f9eaf393 100644 --- a/railties/lib/rails/initializable.rb +++ b/railties/lib/rails/initializable.rb @@ -39,11 +39,6 @@ module Rails select { |i| i.before == initializer.name || i.name == initializer.after }.each(&block) end - def initialize(initializers = []) - super(initializers) - replace(tsort) - end - def +(other) Collection.new(to_a + other.to_a) end @@ -51,7 +46,7 @@ module Rails def run_initializers(*args) return if instance_variable_defined?(:@ran) - initializers.each do |initializer| + initializers.tsort.each do |initializer| initializer.run(*args) end @ran = true @@ -94,4 +89,4 @@ module Rails end end end -end
\ No newline at end of file +end diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index b3f65fd00d..3fe01e543c 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -41,7 +41,7 @@ module RailtiesTest boot_rails - initializers = Rails.application.initializers + initializers = Rails.application.initializers.tsort index = initializers.index { |i| i.name == "dummy_initializer" } selection = initializers[(index-3)..(index)].map(&:name).map(&:to_s) |