From 33239a85e8739ff0ded8aea5d4955522279640be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20G=C3=B3mez?= Date: Fri, 17 Jun 2022 15:38:08 -0230 Subject: [PATCH] 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. --- lib/rake/file_task.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/rake/file_task.rb b/lib/rake/file_task.rb index c36b49699..6d9fd320d 100644 --- a/lib/rake/file_task.rb +++ b/lib/rake/file_task.rb @@ -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 @@ -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