Skip to content

Commit

Permalink
fix quadratic performance in FileTask#out_of_date?
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
doudou committed Sep 19, 2017
1 parent 32dcaa6 commit e58a85f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rake/file_task.rb
Expand Up @@ -30,10 +30,10 @@ def timestamp

# Are there any prerequisites with a later time than the given time stamp?
def out_of_date?(stamp)
@prerequisites.any? { |prereq|
all_prerequisite_tasks.any? { |prereq|
prereq_task = application[prereq, @scope]
if prereq_task.instance_of?(Rake::FileTask)
prereq_task.timestamp > stamp || prereq_task.needed?
prereq_task.timestamp > stamp || @application.options.build_all
else
prereq_task.timestamp > stamp
end
Expand Down

0 comments on commit e58a85f

Please sign in to comment.