aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStavros Aronis <[email protected]>2011-12-09 16:01:58 +0100
committerStavros Aronis <[email protected]>2012-02-22 13:04:27 +0100
commita9b23189c41028b8b4e6e417b3f779253f4d3fe3 (patch)
treea8432584df990cd28310a270777107d10abc97d5
parentd96a00e8a11e4b42617e140e6a759748961346d1 (diff)
downloadotp-a9b23189c41028b8b4e6e417b3f779253f4d3fe3.tar.gz
otp-a9b23189c41028b8b4e6e417b3f779253f4d3fe3.tar.bz2
otp-a9b23189c41028b8b4e6e417b3f779253f4d3fe3.zip
Refactor function selection by Dialyzer's codeserver
-rw-r--r--lib/dialyzer/src/dialyzer_codeserver.erl17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/dialyzer/src/dialyzer_codeserver.erl b/lib/dialyzer/src/dialyzer_codeserver.erl
index 13ca65e4dd..f1e87affbd 100644
--- a/lib/dialyzer/src/dialyzer_codeserver.erl
+++ b/lib/dialyzer/src/dialyzer_codeserver.erl
@@ -292,15 +292,11 @@ table__loop(Cached, Map) ->
{NewCached, Ans} =
case Cached of
{M, Tree} ->
- [Val] = [VarFun || {Var, _Fun} = VarFun <- cerl:module_defs(Tree),
- cerl:fname_id(Var) =:= F,
- cerl:fname_arity(Var) =:= A],
+ Val = find_fun(F, A, Tree),
{Cached, Val};
_ ->
Tree = fetch_and_expand(M, Map),
- [Val] = [VarFun || {Var, _Fun} = VarFun <- cerl:module_defs(Tree),
- cerl:fname_id(Var) =:= F,
- cerl:fname_arity(Var) =:= A],
+ Val = find_fun(F, A, Tree),
{{M, Tree}, Val}
end,
Pid ! {self(), MFA, Ans},
@@ -329,3 +325,12 @@ fetch_and_expand(Mod, Map) ->
Msg = "found no module named '" ++ S ++ "' in the analyzed files",
exit({error, Msg})
end.
+
+find_fun(F, A, Tree) ->
+ Pred =
+ fun({Var, _Fun}) ->
+ (cerl:fname_id(Var) =/= F) orelse
+ (cerl:fname_arity(Var) =/= A)
+ end,
+ [Val|_] = lists:dropwhile(Pred, cerl:module_defs(Tree)),
+ Val.