Skip to content

Commit

Permalink
Merge pull request #393 from da2x/patch-1
Browse files Browse the repository at this point in the history
(Performance) Remove unnecessary I/O syscalls for FileTasks
  • Loading branch information
hsbt committed Mar 25, 2022
2 parents 015286d + abf5e26 commit e45cfc0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/rake/file_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ class FileTask < Task
# Is this file task needed? Yes if it doesn't exist, or if its time stamp
# is out of date.
def needed?
!File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all
begin
out_of_date?(File.mtime(name)) || @application.options.build_all
rescue Errno::ENOENT
true
end
end

# Time stamp for file task.
def timestamp
if File.exist?(name)
File.mtime(name.to_s)
else
begin
File.mtime(name)
rescue Errno::ENOENT
Rake::LATE
end
end
Expand Down

0 comments on commit e45cfc0

Please sign in to comment.