Skip to content

Commit 33239a8

Browse files
Jesús Gómezhsbt
Jesús Gómez
authored andcommitted
Reorder conditions of needed?
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.
1 parent a05e1f3 commit 33239a8

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/rake/file_task.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class FileTask < Task
1515
# is out of date.
1616
def needed?
1717
begin
18-
out_of_date?(File.mtime(name)) || @application.options.build_all
18+
@application.options.build_all || out_of_date?(File.mtime(name))
1919
rescue Errno::ENOENT
2020
true
2121
end
@@ -36,11 +36,7 @@ def timestamp
3636
def out_of_date?(stamp)
3737
all_prerequisite_tasks.any? { |prereq|
3838
prereq_task = application[prereq, @scope]
39-
if prereq_task.instance_of?(Rake::FileTask)
40-
prereq_task.timestamp > stamp || @application.options.build_all
41-
else
42-
prereq_task.timestamp > stamp
43-
end
39+
prereq_task.timestamp > stamp
4440
}
4541
end
4642

0 commit comments

Comments
 (0)