Skip to content

Commit e58a85f

Browse files
committed
fix quadratic performance in FileTask#out_of_date?
FileTask#out_of_date? has been changed in 462e403 to call #needed? which calls #out_of_date? recursively. In some cases, where the graph of dependencies is fairly dense, this leads to quadratic performance when it was linear before. Use #all_prerequisite_tasks to avoid the problem. This also saves a File.exist? test as #timestamp already takes it into account.
1 parent 32dcaa6 commit e58a85f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/rake/file_task.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def timestamp
3030

3131
# Are there any prerequisites with a later time than the given time stamp?
3232
def out_of_date?(stamp)
33-
@prerequisites.any? { |prereq|
33+
all_prerequisite_tasks.any? { |prereq|
3434
prereq_task = application[prereq, @scope]
3535
if prereq_task.instance_of?(Rake::FileTask)
36-
prereq_task.timestamp > stamp || prereq_task.needed?
36+
prereq_task.timestamp > stamp || @application.options.build_all
3737
else
3838
prereq_task.timestamp > stamp
3939
end

0 commit comments

Comments
 (0)