Skip to content

Commit

Permalink
Reorder conditions of needed?
Browse files Browse the repository at this point in the history
1. Asking for a setting option is less expensive than tree transversal on dependant tasks.
2. `out_of_date?` should care about "date" concepts, and not concerning about "build_all" option.

Reordering allows us to remove the "build_all" check in the out_of_date, achieving the quality statement in the second item of the previous list.

Suddenly, there is no need to make a distinction between FileTask or other tasks.
  • Loading branch information
Jesús Gómez committed Jun 17, 2022
1 parent 73a2116 commit d3dc893
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/rake/file_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FileTask < Task
# is out of date.
def needed?
begin
out_of_date?(File.mtime(name)) || @application.options.build_all
@application.options.build_all || out_of_date?(File.mtime(name))
rescue Errno::ENOENT
true
end
Expand All @@ -36,11 +36,7 @@ def timestamp
def out_of_date?(stamp)
all_prerequisite_tasks.any? { |prereq|
prereq_task = application[prereq, @scope]
if prereq_task.instance_of?(Rake::FileTask)
prereq_task.timestamp > stamp || @application.options.build_all
else
prereq_task.timestamp > stamp
end
prereq_task.timestamp > stamp
}
end

Expand Down

0 comments on commit d3dc893

Please sign in to comment.