Skip to content

Commit befa36c

Browse files
author
José Valim
committed
Optimize stale handling
1 parent 5e8f928 commit befa36c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/mix/lib/mix/tasks/compile.elixir.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ defmodule Mix.Tasks.Compile.Elixir do
9898

9999
defp compile_files(true, project, compile_path, to_compile, stale, opts) do
100100
set_compiler_opts(project, opts, ignore_module_conflict: true)
101-
to_compile = lc f inlist to_compile, f in stale, do: f
101+
to_compile = lc f inlist stale, f in to_compile, do: f
102102
compile_files(to_compile, compile_path)
103103
File.touch! Path.join(compile_path, @manifest)
104104
end

lib/mix/lib/mix/utils.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,20 @@ defmodule Mix.Utils do
7575
compared to the given target.
7676
"""
7777
def stale?(sources, targets) do
78-
extract_stale(sources, targets) != []
78+
Enum.any? stale_stream(sources, targets)
7979
end
8080

8181
@doc """
8282
Extract all stale sources compared to the given targets.
8383
"""
8484
def extract_stale(sources, targets) do
85+
stale_stream(sources, targets) |> Enum.to_list
86+
end
87+
88+
defp stale_stream(sources, targets) do
8589
last_modifieds = Enum.map(targets, last_modified(&1))
8690

87-
Enum.filter sources, fn(source) ->
91+
Stream.filter sources, fn(source) ->
8892
source_stat = source_mtime(source)
8993
Enum.any?(last_modifieds, source_stat > &1)
9094
end

0 commit comments

Comments
 (0)