diff options
author | Tristan Sloughter <tristan.sloughter@gmail.com> | 2015-04-25 11:02:16 -0500 |
---|---|---|
committer | Tristan Sloughter <tristan.sloughter@gmail.com> | 2015-04-25 11:02:16 -0500 |
commit | 459746c5b1d8c1c18f2f419e5c7c4b3e5b98092a (patch) | |
tree | c0ee34d3d1760df756fcecb1c555bfe5870b40a9 | |
parent | b0fc3aeb2ef7893cc45087f29658e8e25a31ae60 (diff) | |
parent | bbb6bb2d90779630c92feb5460264afa7b468ebd (diff) |
Merge pull request #372 from ferd/optimize-topsorting
Avoid topsorting deps twice
-rw-r--r-- | src/rebar_prv_install_deps.erl | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 0fa843f..3cd030a 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -82,13 +82,9 @@ do(State) -> ?PRV_ERROR({cycles, Cycles}); {error, Error} -> {error, Error}; - no_cycle -> - case compile_order(Source, ProjectApps) of - {ok, ToCompile} -> - {ok, rebar_state:deps_to_build(State1, ToCompile)}; - {error, Error} -> - {error, Error} - end + {no_cycle, Sorted} -> + ToCompile = cull_compile(Sorted, ProjectApps), + {ok, rebar_state:deps_to_build(State1, ToCompile)} end catch %% maybe_fetch will maybe_throw an exception to break out of some loops @@ -171,17 +167,11 @@ find_cycles(Apps) -> case rebar_digraph:compile_order(Apps) of {error, {cycles, Cycles}} -> {cycles, Cycles}; {error, Error} -> {error, Error}; - {ok, _} -> no_cycle + {ok, Sorted} -> {no_cycle, Sorted} end. -compile_order(Source, ProjectApps) -> - case rebar_digraph:compile_order(Source) of - {ok, Sort} -> - %% Valid apps are compiled and good - {ok, lists:dropwhile(fun not_needs_compile/1, Sort -- ProjectApps)}; - {error, Error} -> - {error, Error} - end. +cull_compile(TopSortedDeps, ProjectApps) -> + lists:dropwhile(fun not_needs_compile/1, TopSortedDeps -- ProjectApps). update_pkg_deps(Profile, Packages, PkgDeps, Graph, Upgrade, Seen, State) -> case PkgDeps of |