Skip to content

Commit e45cfc0

Browse files
authored
Merge pull request #393 from da2x/patch-1
(Performance) Remove unnecessary I/O syscalls for FileTasks
2 parents 015286d + abf5e26 commit e45cfc0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/rake/file_task.rb

+8-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ class FileTask < Task
1414
# Is this file task needed? Yes if it doesn't exist, or if its time stamp
1515
# is out of date.
1616
def needed?
17-
!File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all
17+
begin
18+
out_of_date?(File.mtime(name)) || @application.options.build_all
19+
rescue Errno::ENOENT
20+
true
21+
end
1822
end
1923

2024
# Time stamp for file task.
2125
def timestamp
22-
if File.exist?(name)
23-
File.mtime(name.to_s)
24-
else
26+
begin
27+
File.mtime(name)
28+
rescue Errno::ENOENT
2529
Rake::LATE
2630
end
2731
end

0 commit comments

Comments
 (0)